All Products
Search
Document Center

OpenSearch:Spelling correction

Last Updated:Mar 02, 2023

Overview

If the search queries that you entered contain spelling errors, the search results may not meet expectations or even no search results may be returned. To resolve the issue, OpenSearch checks the spelling of the search queries that you entered. The spelling correction feature for query analysis in OpenSearch corrects the spelling errors that may be contained in a search query and produces a new search query with errors corrected. Then, OpenSearch determines whether to use the new search query with errors corrected to conduct a search based on the credibility of the spelling correction. OpenSearch uses the following logic to conduct a search in the case of spelling correction:

  1. If the credibility of the spelling correction is high, OpenSearch uses the new search query with errors corrected to conduct a search.

  2. If the credibility of the spelling correction is low, OpenSearch uses the original search query to conduct a search.

  3. In the case of spelling correction, OpenSearch adds the original and corrected search queries to the search results.

    {
     "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. Valid values:

    • 1: high credibility

    • 2: low credibility

Procedure

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 click Create.

image

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.

imageNote: If no intervention dictionary for spelling correction is specified, spelling errors are corrected based on the built-in dictionary for spelling correction. If identified spelling errors are invalid or spelling errors are not identified based on the built-in dictionary, specify an intervention dictionary. For more information, see the "Intervention dictionaries for spelling correction" section of this topic.

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

imageThe following figure shows the search results.

The following figure shows how to view the process of query analysis.image

4. After you confirm that the process of query analysis 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.

image

5. Check the default query analysis rule.

image

Intervention dictionaries for spelling correction

An intervention dictionary for spelling correction is a collection of custom intervention entries that are used to correct spelling errors in search queries if the errors are not identified based on the built-in dictionary. After you create an intervention dictionary for spelling correction, you can specify the intervention dictionary when you create or modify a query analysis rule. This way, you can intervene in the spelling correction of search queries. For more information, see Intervention dictionaries for spelling correction.