-
Searching With Coveo
- Get Started With Coveo-Powered Search Pages
- About Queries
- Using Facets
- About the Query Expression
- Coveo Query Syntax
- Search Prefixes and Operators
- Advanced Field Queries
- Query Correction Feature
- Nested Queries
- Are Queries Case-Sensitive?
- About Result Folding
- About Persistent Queries
- About Stemming
- About Search Result Ranking
- Leading Practices for Improving Search Response Time
- Troubleshoot Querying Issues
Query Correction Feature
Coveo supports a query correction feature, also known as Did You Mean, which can suggest substitutes for, or even automatically correct misspelled keywords.
This article explains how to enable this feature in your search interfaces, and provides a high-level overview of the way it works.
Enabling the Feature
In a JavaScript Search Framework interface, you can enable the query correction feature by initializing a DidYouMean
component.
Visually, this component is intended to appear in the results column, above the result list. Most sample search interfaces include this component by default.
<div id="search" class="CoveoSearchInterface">
<!-- ... -->
<div class="coveo-main-section">
<!-- ... -->
<div class="coveo-results-column">
<!-- ... -->
<div class="CoveoDidYouMean"></div>
<!-- ... -->
<div class="CoveoResultList"></div>
<!-- ... -->
</div>
</div>
<!-- ... -->
</div>
By default, the component automatically triggers a new query when no results are returned and a query correction is available. If you want to disable this behavior, set the component’s enableAutoCorrection
option to false
.
<div class="CoveoDidYouMean" data-enable-auto-correction="false"></div>
About the Feature
When a queried term isn’t (or rarely) present in indexed items, by default Coveo looks for any terms with a similar spelling and a significantly higher number of occurrences in your index. When terms that match these conditions are found, the following actions occur:
-
If the current query returns results but more frequently occurring terms with similar spelling are found in the index, a link containing the new terms is provided. Selecting this link triggers a new query using the corrected keywords.
-
If the current query returns no results, and the
DidYouMean
component’senableAutoCorrection
option isn’t explicitly set tofalse
, the keywords are automatically replaced by the most frequently occurring terms with the closest spelling and a new query is triggered.
-
An end user is trying to find a specific movie on your theater’s search page. The end user sends a query with the keywords
Ex Mcanhia
, which returns no results. TheDidYouMean
feature automatically corrects the keywords toEx Machina
and triggers a new query using the new keywords. -
An end user is trying to find a specific movie on your theater’s search page. The end user sends a query with the keywords
Ex Machnia
, which returns a few results. TheDidYouMean
feature suggests that the end user instead uses the keywordsEx Machina
.
Limitations
-
The index must have at least 2,000 items to start providing query corrections.
The relevance of the corrections improves with the size of the index, as more correctly-spelled terms become available for comparison.
-
The Did You Mean feature ignores query keywords that:
-
Are less than four characters long.
-
Contain more than four digits.
-
Begin with a digits.
-
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.
-
-
The Did You Mean feature also doesn’t process queries that were:
-
Processed by a Coveo Machine Learning (Coveo ML) Automatic Relevance Tuning (ART) model, for which the Intelligent Term Detection (ITD) feature is enabled.