autocompleteSearch

Autocomplete Search feature can predict what a user is searching for based on what they have already typed in. It can identify entities within a user's query and suggest them as potential search terms. This feature optimizes the accuracy of the search results by offering relevant suggestions and completing the user's query.

Autocomplete requests are built using the AutocompleteOptions class. The required parameter is the AutocompleteOptions.query for which autocomplete results should be returned. You can also provide optional parameters to perform a more accurate search, following similar recommendation as for search.

This API performs a synchronous Autocomplete Search using the provided AutocompleteOptions object. It delivers the Result using an AutocompleteResponse, or a SearchFailure if the action fails.

Return

The Result contains an AutocompleteResponse if the call succeeds, or a SearchFailure if it fails.

Example of an Autocomplete request:

val autocompleteOptions = AutocompleteOptions(
query = "query",
locale = Locale("en", "US"),
position = GeoPoint(52.379189, 4.899431),
radius = Distance.meters(5000)
)
val response = search.autocompleteSearch(autocompleteOptions)
if (response.isSuccess()) {
val result: AutocompleteResponse = response.value()
Log.d(result.summary.query)
Log.d(result.summary.geoBias)
Log.d(result.summary.results.firstOrNull())
} else {
val failure: SearchFailure = response.failure()
Log.e(failure.message)
}

Parameters

options

The configuration options for the autocomplete search.


Autocomplete Search feature can predict what a user is searching for based on what they have already typed in. It can identify entities within a user's query and suggest them as potential search terms. This feature optimizes the accuracy of the search results by offering relevant suggestions and completing the user's query.

Autocomplete requests are built using the AutocompleteOptions class. The required parameter is the AutocompleteOptions.query for which autocomplete results should be returned. You can also provide optional parameters to perform a more accurate search, following similar recommendation as for search.

This API performs an asynchronous autocomplete search using the provided AutocompleteOptions object. It returns the result using the provided AutocompleteCallback.

Return

Cancellable search operation.

Example of an Autocomplete request:

val autocompleteOptions = AutocompleteOptions(
query = "query",
locale = Locale("en", "US"),
position = GeoPoint(52.379189, 4.899431),
radius = Distance.meters(5000)
)
search.autocompleteSearch(autocompleteOptions, object : AutocompleteCallback {
override fun onSuccess(result: AutocompleteResponse) {
Log.d(result.summary.query)
Log.d(result.summary.geoBias)
Log.d(result.summary.results.firstOrNull())
}
override fun onFailure(failure: SearchFailure) {
Log.e(failure.message)
}
})

Parameters

options

The object which contains the data for the autocomplete search.

callback

The AutocompleteCallback invoked when the search operation has finished, either successfully or with an error. The callback will be executed in the main thread.