All Products
Search
Document Center

Intervention dictionaries for synonym configuration

Last Updated: Sep 09, 2021

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 select the dictionary when you create or modify a query analysis rule. This way, you can intervene in synonym configuration.

Overview

OpenSearch is built in with a dictionary to implement automatic synonym configuration. You can also create custom intervention dictionaries to intervene in synonym configuration on the Dictionary Management page. To intervene in synonym configuration, perform the following steps:

  1. Create an intervene dictionary for synonym configuration. To create an intervention dictionary, log on to the OpenSearch console. In the left-side navigation pane, choose Search Algorithm Center > Retrieval Configuration. On the Basic Configuration page, click Dictionary Management in the left-side pane. On the Dictionary Management page, click Create in the upper-right corner. Specify a name for the intervention dictionary, select a dictionary type, and then click Save. After the intervention dictionary is created, it is displayed in the dictionary list.

  2. Create and manage intervention entries in the intervention dictionary. To go to the entry management page for the created dictionary, find the dictionary in the dictionary list and click Manage Entries in the Actions column. On this page, create and manage intervention entries as needed.

You can intervene in synonym configuration in the following ways:

  • Add a synonym and enable it for a search query. Then, when you conduct a search by using the search query, OpenSearch returns both documents that contain the search query and those that contain the synonym.

  • Add a synonym and block it for a search query. Then, when you conduct a search by using the search query, OpenSearch does not return documents that contain the synonym.

    1. Use the intervention dictionary. After you create intervention entries in the intervention dictionary, you can use the intervention dictionary in a query analysis rule on an application as needed.

    2. Test and publish the intervention dictionary. After you use the intervention dictionary in the query analysis rule, we recommend that you test the search performance before you apply the rule to your online application. This ensures expected search performance.

Matching rules of intervention entries

  • If one or more (up to five) consecutive semantic terms of the custom search query that you specify are not stop words and match the predefined search query in an intervention entry, the intervention entry takes effect.

  • For example, a custom search query is specified as christian dior aj co-branding low-cut sneaker and the following intervention entries are created: christian dior -> dior, aj -> air jordan, and co-branding -> collaboration. In this case, the three intervention entries all take effect. As a result, OpenSearch returns documents that contain one of the eight expanded search queries, such as "dior aj co-branding low-cut sneaker", "dior air jordan co-branding low-cut sneaker", "dior aj collaboration low-cut sneaker", and "dior air jordan collaboration low-cut sneaker".

  • Intervention entries for terms whose weight is higher in the custom search query after analysis take precedence. For example, the following intervention entries are created: sphagitis -> pharyngitis, quinsy, excessive internal heat, sore throat, throat inflammation, low fever -> fever, fervescence, high body temperature, and medicine -> traditional chinese medicine, western medicine, chinese patent drug. A custom search query is specified as "which medicine is best for sphagitis low fever". After analysis, the terms "sphagitis" and "medicine" have a weight of 7, whereas the term "low fever" has a weight of 4. As a result, the intervention entries that take effect are "sphagitis -> pharyngitis, quinsy, excessive internal heat, sore throat, throat inflammation" and "medicine -> traditional chinese medicine, western medicine, chinese patent drug".

  • If multiple terms in the custom search query after analysis have the same weight, the intervention entry for the term that is nearer to the beginning takes precedence. For example, the following intervention entries are created: apple mobile phone -> iphone and mobile phone charger -> power bank. A custom search query is specified as apple mobile phone charger. In this case, the intervention entry that takes effect is apple mobile phone -> iphone.

  • For intervention entries whose predefined search queries share the same beginning, the intervention entry that has a longer predefined search query takes precedence. The length of a predefined search query indicates the number of semantic terms after analysis. For example, the following intervention entries are created: mobile phone charger -> power bank and mobile phone -> cellphone. A custom search query is specified as which mobile phone charger brand is good. In this case, the intervention entry that takes effect is mobile phone charger -> power bank.

  • Human interventions take precedence. If a custom intervention entry conflicts with a built-in intervention entry, only the custom entry takes effect. A conflict indicates the situation in which the predefined search query in an intervention entry includes or is included in the semantic terms that are defined by OpenSearch for the search query. The following examples show the detailed information:

    • Example 1: The predefined search query in an intervention entry includes the semantic terms that are defined by OpenSearch for the search query. The built-in intervention entry involved is "biscuit -> cookie" and a custom search query is specified as baked biscuit. In this case, the logic of the custom search query is expanded to "baked AND (biscuit OR cookie)". If a custom intervention entry baked biscuit -> baked cookie is created, the logic of the custom search query is expanded to "baked biscuit OR baked cookie". The built-in intervention entry "biscuit -> cookie" is omitted.

    • Example 2: The predefined search query in an intervention entry is included in the semantic terms that are defined by OpenSearch for the search query. The built-in intervention entry involved is apple mobile phone -> iphone and a custom search query is specified as "apple mobile phone". In this case, the logic of the custom search query is expanded to "apple mobile phone OR iphone". If a custom intervention entry mobile phone -> cellphone is created, the logic of the custom search query is expanded to "apple AND (mobile phone OR cellphone)".

Notes:

  • The number of synonyms allowed is determined by the number of terms in the specified search query after analysis. The current maximum number of synonyms for a single search query is 36.

Example

Scenario: You have created query analysis rules with synonym configuration capabilities for the OpenSearch application of your e-commerce shopping guide service. After you apply these rules to the online application, invalid synonym configuration results exist. To resolve the issue, intervention in synonym configuration is implemented.

Invalid synonym configuration results: A customer enters the search query "apple" and the documents about the desired commodities are not retrieved. Such documents exist in the database, but they contain the synonym "apple inc." instead of the search query "apple".

Problem description: The built-in dictionary for synonym configuration lacks the intervention entry of "apple -> apple inc.".

Solution: Create an intervention dictionary for synonym configuration and create an intervention entry "apple -> apple inc." for the search query "apple". Then, use the intervention dictionary in a query analysis rule on the online application.

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 Dictionary Management in the left-side pane. On the Dictionary Management page, click Create in the upper-right corner to create an intervention dictionary.

1

In the Create Query Analysis Dictionary panel, specify a name for the intervention dictionary and set the Dictionary Type parameter to Synonym.

2

2.Find the created intervention dictionary and click Manage Entries in the Actions column. On the page that appears, click Add Intervention Entry. In the Add Intervention Entry panel, enter apple in the Search Query field and apple inc. In the Add Synonym field, and click Save.

3

3.Go to the Query Analysis Rule Management page and click Create in the upper-right corner. In the Add Rule panel, associate the created intervention dictionary for synonym configuration with the query analysis rule.

4

4.Perform a search test. OpenSearch returns both documents that contain the search query "apple" and those that contain the search query "apple inc.". The search performance is as expected.

Usage notes

  • You cannot change the name and type of an intervention dictionary after it is created.

  • You must specify different search queries for different intervention entries. You can add, remove, and modify the synonyms to be enabled or blocked for created intervention entries.

  • You can specify multiple synonyms to be enabled or blocked for a single search query. Separate multiple synonyms with semicolons (;).

  • After you create or modify an intervention entry, it enters the Validating state. You can click the Refresh button to update the status of the intervention entry.

  • An intervention dictionary can be used by multiple query analysis rules.

  • OpenSearch uses the built-in dictionaries together with the intervention entries that you create. If you enable synonym configuration when you create a query analysis rule, the built-in dictionary of this intervention type is automatically selected.

  • If an intervention dictionary is used by a query analysis rule, no matter whether the rule is published or not, you cannot delete the dictionary. You must disassociate the dictionary from the rule before you delete the dictionary.

Limits

  • You can create a maximum of 20 intervention dictionaries for synonym configuration.

  • You can specify only one search query when you create an intervention entry for synonym configuration. A maximum number of five synonyms can be enabled or blocked for a single search query.

  • You can create a maximum of 1,000 intervention entries in an intervention dictionary for synonym configuration.

  • An intervention entry takes effect if its predefined search query matches one of the terms in the custom search query after analysis. For example, the following intervention entry is created: "beijing -> capital of china". In this case, if a custom search query is specified as "beijing", OpenSearch returns both documents that contain "beijing" and those that contain "capital of china". If a custom search query is specified as "welcome to beijing", OpenSearch returns both documents that contain "welcome to beijing" and those that contain "welcome to capital of china"

  • OpenSearch normalizes the search queries and synonyms that you specify for intervention entries. OpenSearch converts uppercase letters into lowercase letters and full-width characters into half-width characters.

  • If you use the latest version of the OpenSearch console, you must use the following JSON format when you create multiple intervention entries for synonym configuration at a time:

[{"cmd":"add","word":"hey","alias":["hei","hei2"],"antiAlias":["hi"]}]

If you use the earlier version of the OpenSearch console, you must use the following JSON format when you create multiple intervention entries for synonym configuration at a time:

[{"cmd":"add","word":"hey","alias":["hei","hei2"],"anti_alias":["hi"]}]