Synonym intervention dictionaries

Updated at:

The synonyms of some words vary across business scenarios. As a result, the built-in system dictionary may lack certain synonyms or provide incorrect ones. To address this, the intervention feature lets you define custom synonyms.

To intervene in the synonym feature, create a synonym intervention dictionary and configure it in the synonym settings of query analysis.

Usage

You can manually intervene in the built-in system synonym dictionary. (A synonym intervention dictionary supplements the built-in system dictionary used in "Query Analysis - Synonyms".) The intervention process typically consists of the following four steps:

  1. Create a synonym intervention dictionary. Go to Search Algorithm Center > Retrieval Configuration > Dictionary Management. On the query analysis intervention dictionary page, click "Create" in the upper-right corner. Select a dictionary type and name the dictionary. After the intervention dictionary is created, it appears in the dictionary list on the page.

  2. Add and manage intervention entries in the intervention dictionary. After the dictionary is created, click the dictionary name in the list or click "Manage Entries" for the dictionary to go to the details page of the intervention dictionary. On the details page, you can add and manage intervention entries.

You can perform two types of intervention on a query:

  • Add synonyms: Add synonyms to a query. When the query is searched, the system returns search results that contain either the query or the added synonyms.

  • Block synonyms: Block existing synonyms of a query. When the query is searched, the system no longer also returns search results that contain the blocked synonyms.

    1. Use the intervention dictionary. After you create and populate a synonym intervention dictionary, you can select it in the query rules of any application.

    2. Test the effect of the intervention dictionary and bring it online. After a query analysis rule uses an intervention dictionary, we recommend that you test the search results before you apply the rule online to evaluate whether the effect meets your expectations.

Rules for intervention entries to take effect

  • An intervention takes effect if one semantic term or multiple consecutive semantic terms (up to 5) in the search query, excluding stop words, are identical to the query of an intervention entry.

  • Example of synonym intervention taking effect (Chinese terms are shown as romanizations or English glosses here): The query is Di'ao aj collaborative low-top shoes, and the configured intervention entries are Di'ao->dior, aj->air jordan, and collaborative->cooperative. All three synonym interventions take effect. The search can match the results of 8 queries, such as dior aj collaborative low-top shoes, dior air jordan collaborative low-top shoes, dior aj cooperative low-top shoes, and dior air jordan cooperative low-top shoes.

  • Intervention entries that match terms with higher weights in the search query take precedence. For example, using English glosses for the Chinese terms, the configured intervention entries are laryngopharyngitis -> pharyngitis, tonsillitis, excess internal heat, throat pain, red and swollen throat, low fever -> fever, feeling feverish, high body temperature, and medicine -> traditional Chinese medicine, western medicine, Chinese patent medicine. The query is: what medicine helps recover quickly from laryngopharyngitis and low fever. If laryngopharyngitis and medicine have a weight of 7 and low fever has a weight of 4, the synonyms that are finally retained are laryngopharyngitis -> pharyngitis, tonsillitis, excess internal heat, throat pain, red and swollen throat and medicine -> traditional Chinese medicine, western medicine, Chinese patent medicine.

  • If matched terms in the search query have the same weight, the intervention entry at the earlier position takes precedence. For example, using English glosses for the Chinese terms, with the intervention entries Apple phone->iphone and phone charger->power bank and the query Apple phone charger, the synonym intervention that finally takes effect is Apple phone->iphone.

  • If matches in the search query start at the same position, the length of the intervention entry (the number of semantic terms) takes precedence. That is, the intervention entry with more semantic terms is used first. For example, using English glosses for the Chinese terms, with the intervention entries phone charger-> power bank and phone->mobile phone and the query phone charger: which brand is good?, the synonym intervention that finally takes effect is phone charger -> power bank.

  • User interventions take precedence. If a system synonym conflicts with a user intervention, the user intervention is retained. A conflict occurs when the user-intervened part contains, or is contained in, the range (position) of semantic terms covered by a system synonym. Examples:

    • The user intervention range contains the system range. Using English glosses for the Chinese terms, assume that the system has the synonym baocai -> yuanbaicai (two Chinese names for cabbage). The search query stir-fried baocai is expanded to stir-fried AND (baocai OR yuanbaicai). If the user adds the synonym stir-fried baocai -> stir-fried ganlan, the query is expanded to stir-fried baocai OR stir-fried ganlan. That is, the system synonym yuanbaicai is ignored. Here, baocai, yuanbaicai, and ganlan are different Chinese terms for cabbage.

    • The user intervention range is contained in the system range. Using English glosses for the Chinese terms, assume that the system has the synonym apple phone -> iphone. The search query apple phone is expanded to apple phone OR iphone. If the user adds the synonym phone -> mobile phone, the query is expanded to apple AND (phone OR mobile phone).

Note:

  • The number of synonyms is limited by the number of query groups that are finally generated (currently 36).

Hands-on example

Business scenario: An e-commerce shopping guide business configures a query analysis rule in its OpenSearch application instance. The rule includes the synonym feature. After a bad case is found online, the business decides to use the intervention feature.

Bad case: When users search for the query "apple", relevant products are not returned. The database does contain data about relevant products, but the product descriptions all use the Chinese word for apple.

Diagnosis: The system synonym dictionary does not recognize the Chinese word for apple as a synonym of "apple".

Solution: Create a synonym intervention dictionary, intervene in the query apple in the dictionary by adding the synonym "\u82f9\u679c" (the Chinese word for apple, shown in JSON string notation; decode the Unicode escapes before entering the value), and apply the synonym intervention dictionary to the query analysis rule that is used online.

Procedure:

  1. In the console, go to Search Algorithm Center > Retrieval Configuration > Dictionary Management and create a synonym dictionary:

Enter a "Name" and select "Synonym" as the dictionary type: In the Create Query Analysis Dictionary dialog box, enter dic_tong in the Name field and select Synonym for Dictionary Type.

2. In the new synonym intervention dictionary, add an intervention entry. Enter apple in the Query field and "\u82f9\u679c" in the Add Synonyms field (JSON string notation for the Chinese word for apple; enter the decoded Chinese value):

Also enter pinguo in the Block Synonyms field.

3. On the query analysis page, first apply the newly created synonym intervention dictionary to a query analysis rule that is not online, so that you can test the search results:

In the Add Rule dialog box, select the Synonym check box in the feature list. System Built-in Dictionary is selected by default for the dictionary. Select the synonym intervention dictionary that you created (such as dic_tong) from the Intervention Dictionary drop-down list, and then click OK.

4. Test whether the search meets expectations. The search results include results that contain "\u82f9\u679c" or apple, which meets expectations. The JSON string represents the Chinese word for apple:

On the search test page, Actual Query is represented here as a JSON string (decode it to obtain the original displayed query): "(((default:\"apple\") OR (default:\"\u82f9\u679c\")))", which confirms that the synonym intervention successfully expanded apple to "\u82f9\u679c". The synonym value and the following product-field value use the same JSON string notation. The search results include product records with "cate_name=\u82f9\u679c".

Usage notes

  • The dictionary type and name cannot be modified after the dictionary is created.

  • When you add an intervention entry, the query must not duplicate a query that has already been intervened in the intervention list. For queries intervened in previously, you can add, delete, and modify the added and blocked synonyms directly in the list.

  • To add or block multiple synonyms for a single query, separate the words with semicolons (;).

  • After you add or modify an intervention entry, if the status remains "Taking Effect", you can click the refresh button to synchronize the status.

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

  • Intervention dictionaries currently work as patches on top of the built-in system dictionary. Therefore, the built-in system dictionary is selected by default when you use an intervention dictionary.

  • An intervention dictionary that is used by any query rule (whether online or not) cannot be deleted. To delete it, you must first remove it from the rule.

Limits

  • You can create a total of 20 synonym intervention dictionaries.

  • Each time you add a synonym intervention entry, you can enter only one query. The total number of added and blocked synonyms for the same query must be 5 or fewer.

  • Each synonym intervention dictionary can contain up to 1,000 intervention entries.

  • Synonym intervention entries are matched and take effect based on the terms produced by tokenization. For example, consider the Chinese terms Beijing (the city name) and didu (meaning "imperial capital"). After you add didu as a synonym of Beijing, a search for Beijing returns results that contain either term. A search for the Chinese phrase meaning "Beijing welcomes you" also returns results containing either the original phrase or the phrase meaning "the imperial capital welcomes you". These are English glosses of the Chinese example, rather than claims about how English text is tokenized.

  • When you add an intervention entry, if the query contains English, use all-lowercase English.

  • For the related SDK, see PushInterventionDictionaryEntries.

  • To add synonym intervention entries in batches, use the JSON format shown in the following example.

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

If you are an existing user of the old console, use the following format for batch uploads:

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