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
Example:Search query: "OpenSearch good":
The query before term weight rewriting is:query=default:'opensearch' AND default:'good'
After term weight processing, the query is rewritten as:query=default:'opensearch' RANK default:'good'
Then, OpenSearch retrieves all documents that contain the term opensearch.
Procedure
-
OpenSearch consoleIn the left-side navigation pane, select Retrieval Configuration > Query Analysis Configuration, select the application name and application type (online/offline), and click Create.
-
Enter a rule name, select an index scope and an industry type, then select Word Weight, and then click OK:
Query rewriting policySelect AND. In the Term Weight configuration panel, select System Built-in Dictionary.
-
After the rule is created, run a search test.
In the Query analysis configuration list, find the target rule. In its Actions column, click Search Test. To test the result, on the Search test page, select an application (for example,
changyu3) and the online application type, enter a query (for example,default:'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,Category prediction. If the analysis result is incorrect, click Configure intervention to customize the behavior.
-
After testing, switch to the Index View tab on the query analysis page, and set the custom query analysis rule as the default:
Click Query Analysis View in the upper-right corner to switch to the index view. In the expanded query analysis list, find the target rule and click Set as Default Query Analysis in its Actions column. To cancel a default rule, 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.