The term weight analysis feature evaluates the importance of each term in search queries and quantifies the evaluated importance as a weight. OpenSearch may not use low-importance terms to retrieve documents. This helps increase the number of documents that are retrieved. If the search queries that you entered contain low-importance terms and these terms are involved in the document retrieval process, only a small number of documents may be retrieved based on the search queries.
Overview
For example, you enter the following search query: opensearch good or not.
The original query clause is query=default:'opensearch' AND default:'good or not' before it is rewritten by the term weight analysis feature.
After the original query clause is rewritten by the term weight analysis feature, the new query clause becomes query=default:'opensearch' RANK default:'good or not'.
Then, OpenSearch retrieves all documents that contain the term opensearch.
Procedure
-
In the OpenSearch console, go to Retrieval configuration > Query analysis configuration in the left-side navigation pane. Select the application name and application type (online or offline), and then click Create.
-
In the Add Rule panel, enter a rule name, select indexes, select Word Weight, and then click OK.
For Query rewriting strategy, select AND. In the Term weight configuration panel, select Built-in dictionary.
-
After the rule is created, run a search test.
In the Query analysis configuration list, find the target rule and click Search test in the Actions column. On the Search test page, select an application (for example,
changyu3) and the online application type, enter a query (for example,default:'Is OpenSearch good?'), and then click Search. The actual parsed query is displayed at the bottom of the page, for example,(default:'opensearch' RANK default:'good'). This indicates that the query was tokenized intoopensearchandgood, which are now connected by the RANK operator.In the pop-up window, you can view the original query, the index name, the Query rewriting result, and the processing results from each analysis step, including Spelling correction, Normalization, Tokenization, Stop words, Synonyms, and Category prediction. If the analysis result is incorrect, click Configure intervention to customize the behavior.
-
After you confirm that the process of query analysis is correct, click Index Orientation on the Query Analysis Rule Management page. Then, specify the created query analysis rule as the default query analysis rule.
In the upper-right corner, switch to the Index view. In the query analysis list, find the target rule and click Set as default query analysis in the Actions column. To undo this, click Cancel default rule.
-
Check the default query analysis rule.
A [Default] tag appears before the default rule's name, such as [Default]test_weight. This tag helps you identify the default rule in the configuration list.
Intervention dictionaries for term weight analysis
The terms that are extracted from the same search query after query analysis may be of different weights in different business scenarios. The settings of term weights in the built-in dictionary may not meet your requirements. To resolve the issue, OpenSearch allows you to customize term weights. After you create an intervention dictionary for term weight analysis, you can specify the intervention dictionary when you create or modify a query analysis rule. This way, you can intervene in the analysis of term weights. For more information, see Intervention dictionaries for term weight analysis.