Answers
<Answers searchClient={object} queryLanguages={string[]} // Optional parameters attributesForPrediction={string[]} nbHits={number} renderDebounceTime={number} searchDebounceTime={number} answersComponent={React.Node} /> // Or as hook: import { EXPERIMENTAL_useAnswers: useAnswers } from 'react-instantsearch-dom'; const { hits, isLoading, } = useAnswers({ searchClient, queryLanguages, // optional attributesForPrediction, nbHits, renderDebounceTime, searchDebounceTime, });
About this widget
The Answers
widget enables semantic search on an existing index. It lets you bring your users directly to the part of your content that answers their questions.
The public API of this widget may change in the near future. Thus, there is the EXPERIMENTAL_
prefix.
Examples
1
2
3
import { EXPERIMENTAL_Answers: Answers } from 'react-instantsearch-dom';
<Answers searchClient={searchClient} queryLanguages={['en']} />
Props
searchClient
|
type: object
Required
The search client passed to |
||
Copy
|
|||
queryLanguages
|
type: string[]
Required
The languages in the query. Only supports |
||
Copy
|
|||
attributesForPrediction
|
type: string[]
default: ["*"]
Optional
Attributes to use for predictions. If using the default ( |
||
Copy
|
|||
nbHits
|
type: number
default: 1
Optional
Maximum number of answers to retrieve from the Answers Engine. Can’t be greater than 1000. |
||
Copy
|
|||
searchDebounceTime
|
type: number
default: 100
Optional
Search debounce time in milliseconds. |
||
Copy
|
|||
renderDebounceTime
|
type: number
default: 100
Optional
Render debounce time in milliseconds. |
||
Copy
|
|||
answersComponent
|
type: React.Node
Optional
Changes the appearance of the default answers widget. |
||
Copy
|
HTML output
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<div class="ais-Answers">
<div class="ais-Answers-header">
...
</div>
<div class="ais-Answers-loader">
...
</div>
<ul class="ais-Answers-list">
<li class="ais-Answers-item">
...
</li>
<li class="ais-Answers-item">
...
</li>
...
</ul>
</div>