Why do queries gets auto-corrected to a different query?
Problem
The search interface auto-corrects queries to a suggested query, rather than searching for the query user entered. For example, the user enters a query watch
in the search box, it corrects to witch
(or watcher
) and return results for the term witch
(or watcher
).
It mostly occurs if you are using an older version of the integration or if you created a custom search UI.
Solution
The autocomplete model auto-corrects misspellings and auto-completes query to suggested queries, based on the data in your collection. This is useful especially for integrations that use instant search feature, where the query is completed on each key stroke as the user continues to type their search term.
However, when the user presses ‘Enter/Return' key after typing a term, the autocomplete suggestion should be overridden and the term entered by the user should take precedence.
To allow users to override the autocompleted/auto-corrected suggestion:
Add
"q.override": "true"
to the query request.Test this by adding this to the Advanced query editor in the Preview section. The query should look like:
{ "q": "watch", "filter": "_id != ''", "fields": "", "q.override": "true" }
CODEIf you are setting up the search UI using the Search UI Designer, then the above mentioned param should be added to the variables configuration of the search snippet.