Query correction feature
Query correction feature
Coveo supports a query correction feature (also known as Did You Mean). This feature can suggest substitutes for, or even automatically correct, misspelled keywords. It also provides suggestions for properly spelled keywords.
The query correction feature will first try to use an index-based system to provide potential corrections.
If the index-based system can’t provide any corrections, a second fallback system based on a Coveo Machine Learning (Coveo ML) Query Suggestion (QS) model will be used. As such, you should make sure that your QS model is correctly configured.
Example
A user is trying to find a specific movie (Ex Machina) on your theater’s search page.
They send a query with the misspelled keywords Ex Manchia.
-
If the query doesn’t return any results: The query correction feature automatically corrects the keywords to
Ex Machina, becauseEx Machinais similar, and triggers a new query using the new keywords.
-
If the query only returns a few results: The query correction feature displays the results but suggests the keywords
Ex Machinato the user.
About the query correction systems
You won’t have to choose between the index-based and QS-based query correction systems. Both have specific features and limitations, and they work together to provide the best possible corrections in most situations.
|
|
Note
Generally, the query correction feature doesn’t correct queries that were processed by a Coveo ML Automatic Relevance Tuning (ART) model for which the Intelligent Term Detection (ITD) feature is enabled. In rare cases, however, the query correction feature may process these queries. |
Features of the index-based system
Limitations of the index-based system
This system will ignore keywords that:
-
Are less than four characters long
-
Occur less than five times in the index
-
Contain more than four digits
-
Begin with a digit
-
Contain seven or more consecutive consonants
-
Contain six or more consecutive vowels
-
Contain an invalid number of consecutive vowels, considering the item language
-
Contain wildcard expressions
-
Are too different from the proposed correction relative to their length, as measured by edit distance
Features of the QS-based system
-
This system only considers queries which resulted in clicks on search results a specific number of times.
-
Its suggestions are based on the query performance of a potential correction, captured through Coveo Analytics metrics.
-
It considers the degree to which the potential correction matches the typed characters.
Limitations of the QS-based system
-
This system requires a correctly configured QS model.
Prerequisite
A correctly configured QS model must be configured and available in your Coveo organization. This model will be used to propose the best available correction to users.
Configure the feature
Depending on the Coveo technology that you use to build your search interfaces, see:
Query correction in the Search API
If you’re using the Coveo Search API directly, you can use the queryCorrection parameter to enable and control the query correction feature.
You can then interpret correction data in the response body.
This section covers the available parameters, how they differ from legacy options, and how to read the correction response.
Difference between query correction and the Did You Mean parameters
The Coveo Search API offers two ways to request keyword corrections:
-
The
queryCorrectionparameter is the enhanced and recommended approach. It combines the index-based and Coveo Machine Learning (Coveo ML) correction systems, and it can automatically correct and re-execute a query that returns no results. Unlike the Did You Mean parameters, it also accounts for thesaurus rules and partial match when computing corrections. -
The Did You Mean parameters (that is, the
enableDidYouMeanandenableMLDidYouMeanparameters) are the legacy approach, kept for backward compatibility. They enable the index-based and Coveo ML Did You Mean features individually, only return correction suggestions, and never automatically correct or re-execute a query.
For new integrations, use the queryCorrection parameter rather than the Did You Mean parameters.
The two approaches return corrections in differently named response properties: query correction uses queryCorrection, while the Did You Mean parameters use queryCorrections.
|
|
Note
The You therefore don’t need to enable the Did You Mean parameters to use the query correction feature, and leaving them enabled alongside query correction has no effect. |
Understanding the query correction response
When you enable the query correction feature through the queryCorrection parameter, correction information is returned in the queryCorrection property of the response.
How you interpret it depends on whether the original query returned results and on the automaticallyCorrect option:
-
When the original query returns no results and automatic correction is turned on (
automaticallyCorrectset towhenNoResults, which is the default value), the Search API corrects the keywords, re-executes the corrected query, and returns its results. TheoriginalQueryandcorrectedQueryproperties are populated, and thecorrectionsarray is empty. The returned results are those of the corrected query, not the original one. -
When the original query returns results, or when automatic correction is turned off (
automaticallyCorrectset tonever), the query isn’t corrected. The correction is returned in thecorrectionsarray instead, whileoriginalQueryandcorrectedQuerystay empty. The returned results are those of the original query, not the suggested correction. To apply a suggestion, the end user must re-execute the query with the corrected keywords, for example by clicking a Did you mean link.