Function
The word dictionaries of an Elasticsearch/OpenSearch cluster in CSS is used for word segmentation of text, enabling special words to be recognized during segmentation and facilitating text data search by keywords. For example, you can search by trending terms such as xidapuben. It also supports searching text data using synonyms based on a synonym dictionary. The analyzers used by CSS include the IK analyzer and the synonym analyzer. The IK analyzer has a main word dictionary and a stop word dictionary. The synonym analyzer has a synonym dictionary. The IK tokenizer supports ik_max_word and ik_smart segmentation policies. The synonym analyzer uses the ik_synonym segmentation policy. This API is used to load a custom dictionary stored in OBS. When the preset word dictionaries cannot meet the word segmentation requirements of the cluster, a custom dictionary can be used.
URI
POST /v1.0/{project_id}/clusters/{cluster_id}/thesaurus
Table 1 Path Parameters | Parameter | Mandatory | Type | Description |
| project_id | Yes | String | Definition Project ID. For details about how to obtain the project ID and name, see Obtaining the Project ID and Name. Constraints N/A Range Project ID of an account. The value contains 32 characters, consisting of lowercase letters and digits. Default Value N/A |
| cluster_id | Yes | String | Definition ID of the cluster where a custom word dictionary you want to configure. For details about how to obtain the cluster ID, see Obtaining the Cluster ID. Constraints N/A Range The value is a UUID containing 36 characters. Default Value N/A |
Request Parameters
Table 2 Request body parameters | Parameter | Mandatory | Type | Description |
| bucket_name | Yes | String | Definition OBS bucket where the word dictionary file is stored. Constraints The storage class of the bucket must be standard or infrequently accessed. Archive storage is not supported. The bucket name can contain 3 to 63 characters. Only lowercase letters, digits, hyphens (-), and periods (.) are allowed. Range N/A Default Value N/A |
| main_object | No | String | Definition: Main word dictionary file. Constraints: -
Must be a text file encoded in UTF-8 without BOM. Each line contains one word. The maximum file size is 100 MB. -
Modify the parameters of at least one of the seven word dictionaries. Note: Passing an empty "" character string will clear the word dictionary. Passing nothing or null will leave the word dictionary unchanged. Value range: N/A Default value: N/A |
| stop_object | No | String | Definition Stop word dictionary file. Constraints -
The value must be a text file encoded in UTF-8 without BOM. Each line contains one word. The maximum file size is 100 MB. -
Modify the parameters of at least one of the seven word dictionaries. Note: Passing an empty "" string will clear the word dictionary. Passing nothing or null will leave the word dictionary unchanged. Range N/A Default Value N/A |
| synonym_object | No | String | Definition Synonym dictionary file. Constraints -
The value must be a text file encoded in UTF-8 without BOM. Each line contains one word. The maximum file size is 100 MB. -
Modify the parameters of at least one of the seven word dictionaries. Note: Passing an empty "" string will clear the word dictionary. Passing nothing or null will leave the word dictionary unchanged. Range N/A Default Value N/A |
| static_main_object | No | String | Definition: Static main word dictionary file. Constraints: -
Must be a text file encoded in UTF-8 without BOM. Each line contains one group of related words. The maximum file size is 100 MB. -
Modify the parameters of at least one of the seven word dictionaries. Note: Passing an empty "" character string will clear the word dictionary. Passing nothing or null will leave the word dictionary unchanged. Only new clusters created after this word dictionary function was brought online are supported. Value range: N/A Default value: N/A |
| static_stop_object | No | String | Definition: Static stop word dictionary file. Constraints: -
Must be a text file encoded in UTF-8 without BOM. Each line contains one group of related words. The maximum file size is 100 MB. -
Modify the parameters of at least one of the seven word dictionaries. Note: Passing an empty "" character string will clear the word dictionary. Passing nothing or null will leave the word dictionary unchanged. Only new clusters created after this word dictionary function was brought online are supported. Value range: N/A Default value: N/A |
| extra_main_object | No | String | Definition: Extra main word dictionary file. Constraints: -
Must be a text file encoded in UTF-8 without BOM. Each line contains one group of related words. The maximum file size is 100 MB. -
Modify the parameters of at least one of the seven word dictionaries. Note: Passing an empty "" character string will clear the word dictionary. Passing nothing or null will leave the word dictionary unchanged. Only new clusters created after this word dictionary function was brought online are supported. Value range: N/A Default value: N/A |
| extra_stop_object | No | String | Definition: Extra stop word dictionary file. Constraints: -
Must be a text file encoded in UTF-8 without BOM. Each line contains one group of related words. The maximum file size is 100 MB. -
Modify the parameters of at least one of the seven word dictionaries. Note: Passing an empty "" character string will clear the word dictionary. Passing nothing or null will leave the word dictionary unchanged. Only new clusters created after this word dictionary function was brought online are supported. Value range: N/A Default value: N/A |
Response Parameters
Status code: 200
Request succeeded.
None
Example Requests
Enable and configure the word dictionary.
POST https://{Endpoint}/v1.0/{project_id}/clusters/4f3deec3-efa8-4598-bf91-560aad1377a3/thesaurus
{
"bucket_name" : "test-bucket",
"main_object" : "word/main.txt",
"stop_object" : "word/stop.txt",
"synonym_object" : "word/synonym.txt",
"static_main_object" : "word/staticMain.txt",
"static_stop_object" : "word/staticStop.txt",
"extra_main_object" : "word/extraMain.txt",
"extra_stop_object" : "word/extraStop.txt"
} Status Codes
| Status Code | Description |
| 200 | Request succeeded. |
| 403 | Request rejected. The server has received the request and understood it, but refused to respond to it. The client should not repeat the request without modifications. |
| 500 | The server is able to receive the request but unable to understand the request. |