The search queries that you entered may have synonyms that carry the same meaning. For example, when you search for Apple phone, you may want the search results to contain the entries that hit either Apple phone or iPhone. In real life, many synonyms that carry the same meaning may exist. A single search query that you entered may not reflect all its synonyms. The capabilities to identify synonyms and conduct searches based on the synonyms are critical to increasing the retrieval rate. The synonym configuration feature of OpenSearch retrieves documents based on the synonyms of search queries. This increases the number of documents that are retrieved. For example, drink and beverage are synonyms. If the synonym configuration feature is disabled, when you search for drink, documents that hit beverage are not retrieved in the search results. If the synonym configuration feature is enabled, documents that hit beverage are retrieved.
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.
2. In the Create Rule panel, enter a rule name, specify an index range, select an industry type, select Synonym, and then click OK.
Note: If no intervention dictionary for synonym configuration is specified, the built-in dictionary for synonym configuration is used. If identified synonyms are invalid or synonyms are not identified based on the built-in dictionary, specify an intervention dictionary. For more information, see the "Intervention dictionaries for synonym configuration" section of this topic.
3. After the rule is created, run a search test.
The following figure shows the search results.The following figure shows how to view the process of query analysis.
4. After you confirm that the process of query analysis is correct, click Index Orientation on the Query Analysis Rule Configuration page. Then, specify the created query analysis rule as the default query analysis rule.
5. Check the default query analysis rule.
Intervention dictionaries for synonym configuration
Synonyms vary with business scenarios. Specific synonyms may not exist in the built-in dictionary for synonym configuration, or the built-in dictionary may contain invalid synonyms. To resolve the issue, OpenSearch allows you to customize synonyms. After you create an intervention dictionary for synonym configuration, you can specify the intervention dictionary when you create or modify a query analysis rule. This way, you can intervene in synonym configuration. For more information, see Intervention dictionaries for synonym configuration.