All Products
Search
Document Center

Spelling correction

Last Updated: Sep 09, 2021

Overview

If the search queries entered by users 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 entered by users. The spelling correction feature in the query analysis feature of 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, choose Search Algorithm Center > Retrieval Configuration. On the Basic Configuration page, click Query Analysis Rule Management in the left-side pane.

1

2.On the Query Analysis Rule Management page, select an application name and the online or offline version of the application, and click Create.

2

3.In the Add Rule panel, enter a rule name, select indexes, select Spelling Correction, and then click OK.

3

Note: 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.

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

5

View the process of query analysis:

6

5.After you confirm that the process of query analysis is correct, switch to Index Orientation on the Query Analysis Rule Management page. Then, set the created query analysis rule as the default query analysis rule.

7

6.Check the default query analysis rule.

8

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.