All Products
Search
Document Center

OpenSearch:Spelling correction

Last Updated:Aug 22, 2026

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:

ValueCredibilitySearch behavior
1HighOpenSearch uses the corrected query
2LowOpenSearch uses the original query

Enable spelling correction

  1. 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.

  2. In the Create Rule panel, enter a rule name, specify an index range, select an industry type, select Spelling Correction, and then click OK.

    Note

    If 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.

  3. After the rule is created, run a search test.

    In the query analysis rule list, find the target rule and click Search Test in the Actions column. On the search test page, enter a query that contains a spelling error (for example, a misspelled product name in the default index), set the qp parameter to test_error, and then click Search. The notification bar at the bottom of the page displays the correction result, indicating that the misspelled query is automatically corrected and the corrected query is used for the search.

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

    On the search test page, enter a query that contains a spelling error and open the Query Analysis Process dialog box. The dialog box shows the following analysis steps: Spelling Correction corrects the misspelled term to the intended term (correction level: full replacement of the corrected query), Normalization returns the corrected term, Tokenization splits the corrected term into tokens, and the final query is rewritten using those tokens in the default index. The search results page shows that the search ran against the corrected query.

  4. 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.

  5. Verify that the default query analysis rule is set correctly.

    After a query analysis rule is set as the default, the [Default] prefix is displayed before the rule name. For example, [Default]test_error.

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.