Algolia InstantSearch Hook - search for an array of objectIDs - algolia

we're using Algolia's InstantSearch React hook
I figured I could do something like the following
<InstantSearch
indexName={indexName}
searchClient={algoliaClient}
searchState={{
query: [
"objectID:80066451052",
"objectID:50090402178"]
}}>
<Configure clickAnalytics />
{children}
</InstantSearch>
But it turns out that the InstantSearch hook does not support searchState the way the older InstantSearch component does.
So can anyone help me turn the query above into one that will work with the InstantSearch hook?

I don't know which version you're using and how your index is configured.
However, the query can be passed directly to the Configure component like any other search parameter you can found here
https://www.algolia.com/doc/api-reference/search-api-parameters/
So you can write this
<InstantSearch
indexName={indexName}
searchClient={algoliaClient}
>
<Configure query={myQuery} clickAnalytics/>
{children}
</InstantSearch>

Related

How to find form submit input in Protractor

For fun/practice I write a test for Google advanced search and I am looking for a locator that will allow to find the form submit on https://www.google.com/advanced_search:
<input class="jfk-button jfk-button-action dUBGpe"
style="-webkit-user-select:none;user-select:none;line-height:100%;height:30px;min-width:120px"
value="Wyszukiwanie zaawansowane" type="submit">
As you can see this submit does not have id nor name defined so by.id() or by.name() cannot be used.
by.css locates elements using a CSS selector. It allows you to simply use attribute selectors for locating elements in the DOM.
element(by.css('input[type="submit"]'))
To find the form submit the by.xpath locator can be used:
element(by.xpath("//input[#type='submit']"));
What locator will suite You depends of the whole page, but here are few locators you can try:
element(by.xpath("//input[#class='jfk-button jfk-button-action dUBGpe']"));
element(by.css("jfk-button.jfk-button-action.dUBGpe"));

How to configure a dynamic autocomplete in Orbeon Forms?

I need to use a dynamic autocomplete based on ws rest to show suggestions of my field. I used it but it didn't work, it didn't update the list of suggestions. Example:
<fr:autocomplete
id="control-3-control"
appearance="minimal"
labelref="#label"
resource="http://127.0.0.1/api/ws/pays/all"
bind="control-3-bind">
<xf:label ref="$form-resources/control-3/label"/>
<xf:hint ref="$form-resources/control-3/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
<xf:itemset ref="./_">
<xf:label ref=".//libelle"/>
<xf:value ref=".//id"/>
</xf:itemset>
</fr:autocomplete>
And this is the screenshot:
Doing the "filtering" based on the value entered by users is the responsibility of the service the autocomplete is calling. However, it can't do this if you don't provide it with the current value of the field. For this, use {$fr-search-value} somewhere in the URL, e.g. something like:
http://127.0.0.1/api/ws/pays/all?search={$fr-search-value}
And of course, then your service needs to take the value of the search request parameter into account. The autocomplete component will automatically call the service again and again, as necessary as users type in the field.
This allows you to search in a large dataset without having to return the whole set of possible values to Orbeon Forms.

Adding suggestionItems Fails: "Cannot add direct child without default aggregation defined for control sap.m.SearchField"

I am adding a SearchField with suggestions in the XML view. When I execute, I get the error
Error: Cannot add direct child without default aggregation defined for control sap.m.SearchField.
Please tell me what mistake I am making.
<SearchField
placeholder="final search"
tooltip="Search for datastore source names"
suggestionItems="{/records}"
selectOnFocus="true"
>
<suggestionItems>
<SuggestionItem
text="{dbname}"
description="{dbname}"
/>
</suggestionItems>
</SearchField>
Try to have a look to this example
sap.m.Input
suggestionItems="{/ProductCollection}" is the collection with all the available entries, text="{Name}" is one of the attributes of the collection item.
Check this example without search help https://sapui5.hana.ondemand.com/sdk/explored.html#/sample/sap.m.sample.InputSuggestionsDynamic/preview or https://sapui5.hana.ondemand.com/sdk/explored.html#/sample/sap.m.sample.InputSuggestionsCustomFilter/preview
You must be using an old UI5 version. The aggregation suggestionItems was introduced in 1.34.
Here, you can see that the app crashes throwing the same error if run with the version lower than 1.34: https://jsbin.com/qepojux/edit?html,js,output
To see with which UI5 version the app is currently running, press Ctrl+Left Alt+Shift+P.
See also Versioning of SAPUI5.

grails access form attributes in controller

In grails i have a form with g:field tags like:
<g:field name="test" from="0..20"/>
I am trying to find a way how I can access the "from" attribute in my controller.
I can get the "value" attribute by using:
print params.test
I have tried:
print params.test.from
I'm sure there must be a way to do this but I can not seem to find it.
What I am wanting to achieve by this is perform validation so that the value does not go outside the the from range.
I know that this can be added in the domain, but in my situation I need to allow the user to overwrite the range constraints.
Any ideas?
By the time that code hits the browser, it is just HTML. from doesn't exist anymore. If that is being rendered into some sort of client side validation, that's not going to get submitted back to the server in a form submit.
If you explain what you are really needing to do in your question, I can provide a better answer.
You can pass the "from" values as hidden fields.
<g:hiddenField name="min" value="0" />
<g:hiddenField name="max" value="20" />
Something like that.

Can you operate on XML / HTML documents in node.js?

Is it possible to load an XML / HTML document with node.js and perform operations such as getElementsByTagName ?
node.js doesn't give you a DOM "out of the box", but there is a great module that provides a proper HTML DOM: https://github.com/tmpvar/jsdom.
Edit: there are also several modules that help with interacting with XML. Here's a list of them on the wiki (this page is deprecated): https://github.com/joyent/node/wiki/modules#wiki-parsers-xml
Cheerio: Tiny, fast, and elegant implementation of core jQuery designed specifically for the server.
var cheerio = require('cheerio'),
$ = cheerio.load('<h2 class="title">Hello world</h2>');
$('h2.title').text('Hello there!');
$('h2').addClass('welcome');
$.html();
//=> <h2 class="title welcome">Hello there!</h2>
Also check out https://github.com/robtweed/ewdDOM
This is a persistent DOM implementation using the Globals database