Spelling correction detects and fixes typos in search queries so users get relevant results even when their input contains errors. When OpenSearch detects a potential correction, it decides whether to run the search against the corrected query or the original, based on how confident it is in the correction.
How spelling correction works
OpenSearch evaluates each search query for spelling errors and applies the following logic:
If the credibility of the correction is high (
correction_level: 1), OpenSearch uses the corrected query.If the credibility of the correction is low (
correction_level: 2), OpenSearch uses the original query.
In both cases, the search response includes both the original and corrected queries under the qp field:
{
"qp": [
{
"app_name": "The name of the OpenSearch application that is used for the search",
"query_correction_info": [
{
"index": "The name of the index that is used for the search",
"original_query": "The original search query",
"corrected_query": "The new search query with errors corrected",
"correction_level": 1
}
]
}
]
}
The correction_level field indicates the credibility of the spelling correction:
| Value | Credibility | Search behavior |
|---|---|---|
1 |
High | OpenSearch uses the corrected query |
2 |
Low | OpenSearch uses the original query |
Enable spelling correction
Log on to the OpenSearch console. In the left-side navigation pane, click Retrieval Configuration. On the Basic Configuration page, click Query Analysis Rule Configuration in the left-side pane. On the Query Analysis Rule Configuration page, select an application and the online or offline version of the application, and then click Create.

In the Create Rule panel, enter a rule name, specify an index range, select an industry type, select Spelling Correction, and then click OK.
NoteIf no intervention dictionary is specified, OpenSearch corrects spelling errors using the built-in dictionary. If identified spelling errors are invalid, or if spelling errors are not identified based on the built-in dictionary, specify an intervention dictionary. For details, see Intervention dictionaries for spelling correction.
After the rule is created, run a search test.

To view the query analysis process, click the query analysis details.

After you confirm that the query analysis process is correct, click Index Orientation on the Query Analysis Rule Configuration page, then set the created query analysis rule as the default query analysis rule.

Verify that the default query analysis rule is set correctly.

Intervention dictionaries for spelling correction
An intervention dictionary is a collection of custom correction entries that supplement the built-in dictionary. Use an intervention dictionary when the built-in dictionary does not identify a spelling error, or when the built-in dictionary identifies a correction that is invalid for your use case.
After you create an intervention dictionary, specify it when creating or modifying a query analysis rule to override or extend the built-in correction behavior. For more information, see Intervention dictionaries for spelling correction.
