useSearch
useSearch
provides a way to perform a search using the current context or a custom one-off search.
Usage
Returns results for the current query. By default it will use the Variables and Pipeline from the context:
Editable Example
​
Suggestions
Optionally pass in Variables or Pipeline:
Editable Example
Show
Multiple searches
As in the above example, it's possible to perform one off searches using the useSearch
hook. This means we can build a page that performs multiple searches, for example within different categories.
Note: each category search request must use it's own pipeline.
Editable Example
Audio
Loading...
Computers & Tablets
Loading...
TV & Home Theater
Loading...
Anatomy
useSearch
returns an object containing the following properties:
Name | Type | Default | Description |
---|---|---|---|
results | Result[] | An array of results that met the query. See the JS SDK for detailed object shape. | |
latency | number | The engine latency. | |
totalResults | number | The total count of results. | |
search | (q?: string) => void | The search method, call without param to resend the search request with the current query. | |
searching | boolean | Is a search request being processed. | |
error | Error | null | The error encountered while searching. | |
redirects | { [redirectQuery: string]: RedirectTarget } | {} | An object which maps a search string, redirectQuery , to possible redirect completions for that string. See the JS SDK for detailed object shape. |
activePromotions | ActivePromotion[] | [] | An array of active promotions on this result. See the JS SDK for detailed object shape. |
featureScoreWeight | number | 0 | Meta info about this query, feature score weight determines the weighting of featureScore vs neural and index scores. |
banners | Banner[] | 0 | An array of banners. |
Parameters
Name | Type | Default | Description |
---|