Searcher
About this widget
Objects conforming to the Searcher protocol manage the search sessions.
Algolia provides you with several out of the box searchers to help build your InstantSearch experience:
HitsSearcher
: searches a single index.FacetSearcher
: searches for facet values.MultiSearcher
: aggregates the hits and facet searchers. This is useful for a federated search, or query suggestions .AnswersSearcher
: searches an index forAnswers
.
Examples
Instantiate a HitsSearcher
.
1
2
3
let searcher = HitsSearcher(appID: "YourApplicationID",
apiKey: "YourSearchOnlyApiKey",
indexName: "index_name")
Instantiate a FacetSearcher
.
1
2
3
4
let searcher = FacetSearcher(appID: "YourApplicationID",
apiKey: "YourSearchOnlyApiKey",
indexName: "index_name",
facetName: "facet_name")
Instantiate a MultiSearcher
.
1
2
3
4
5
6
let searcher = MultiSearcher(appID: "YourApplicationID",
apiKey: "YourSearchOnlyApiKey")
searcher.addHitsSearcher(indexName: "index_name1")
searcher.addFacetsSearcher(indexName: "index_name1",
attribute: "facet_name")
searcher.addHitsSearcher(indexName: "index_name2")
Instantiate a AnswersSearcher
1
2
3
let searcher = AnswersSearcher(appID: "YourApplicationID",
apiKey: "YourSearchOnlyApiKey",
indexName: "index_name")
HitsSearcher
indexName
|
type: String
Required
The index to search. |
||
Copy
|
|||
query
|
type: Query
default: Query()
Optional
The query used when doing a search. |
||
Copy
|
FacetSearcher
indexName
|
type: String
Required
The index to search into. |
||
Copy
|
|||
facetName
|
type: String
Required
The facet name to search into when doing search for facet values. |
||
Copy
|
|||
query
|
type: Query
default: Query()
Optional
The Query used when doing a search. |
||
Copy
|
AnswersSearcher
indexName
|
type: String
Required
The index to search into for Answers. |
||
Copy
|
|||
query
|
type: AnswersQuery
Optional
The query used when performing an Answers search. |
||
Copy
|
Methods
search
|
Triggers the search. Notifies all listeners of the results. |
||
Copy
|
|||
cancel
|
Cancels all ongoing search requests. |
||
Copy
|
Events
isLoading
|
Triggered when the |
||
Copy
|
|||
onQueryChanged
|
Triggered when the query text is modified. |
||
Copy
|
|||
onResults
|
Triggered when a new search result is received. |
||
Copy
|
|||
onError
|
Triggered when a new error is received. |
||
Copy
|