Call the UpdateHotIkDicts to upload a dictionary and update the IK hotword Dictionary of the Alibaba Cloud Elasticsearch (ES) instance.

Note the following when calling this interface:

If the uploaded dictionary file is from an OSS bucket, make sure that the OSS bucket is public-read.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request header

UT /openapi/instances/{instanceId}/ik-hot-dict

Request syntax

PUT /openapi/instances/[InstanceId]/ik-hot-dict HTTPS|HTTP

Request parameters

Parameter Type Required Example Description
InstanceId String Yes es-xx-123

The ID of the instance.

clientToken String No 5A2CFF0E-5718-45B5-9D4D-70B3FF****

A unique token generated by the client to guarantee the idempotency of the request. You can use the client to generate the value, but you must ensure that it is unique among different requests. The token can only contain ASCII characters and cannot exceed 64 characters in length.

Body request parameters

Parameter

Type

Required

Example

Description

name

String

Yes

1.txt

The name of the uploaded dictionary file.

ossObject

No

The description of the OSS object in the open storage environment. This parameter is required when the sourceType parameter is set to OSS.

└bucketName

String

No

search-cloud-test-cn-shenzhen

The name of the OSS bucket.

└key

String

No

synonym_txt/1.txt

The Key of the Object, that is, the ObjectKey of the open storage.

sourceType

String

Yes

OSS

The source type of the synonym. Valid values: OSS (open storage) and ORIGIN (dictionary applied in a cluster). If the object storage service (OSS) bucket is set to public-read, make sure that it is set to public-read.

type

String

Yes

MAIN

The type of the dictionary. Valid values: STOP, MAIN, SYNONYMS, and ALI_WS.

Note Optional represents a child parameter.

Response parameters

Parameter Type Example Description
Result Array

The returned results.

fileSize Long 6

The size of the synonym dictionary file in bytes.

name String ik_main

The name of the object corresponding to OSS.

ossObject Struct

The description of OSS open storage objects.

bucketName String jcj-oss-new

The name of an OSS bucket.

etag String 5B3C1A2E053D763E1B002CC607C5A0FE1****

The 32-bit uppercase value generated after MD5 encryption.

key String synonym_txt/0.txt

The path of the corresponding IK hotword dictionary file in OSS.

sourceType String OSS

The type of the data source. for example, OSS.

type String MAIN

MAIN and STOP:

  • MAIN: The IK MAIN word dictionary.
  • STOP:IK stopword Dictionary.
RequestId String 5FFD9ED4-C2EC-4E89-B22B-1ACB6FE1****

The ID of the request.

Examples

Sample requests

PUT /openapi/instances/[InstanceId]/ik-hot-dict HTTP/1.1
Common request headers
{
"InstanceId": "es-xx-123"
}

Request body

// Body request example
[
    {
        "name":"deploy_0.dic",
        "ossObject":{
            "bucketName":"search-cloud-test-cn-hangzhou",
            "key":"user_dict/dict_0.dic"
        },
        "sourceType":"OSS",
        "type":"MAIN"
    },
    {
        "name":"SYSTEM_MAIN.dic",
        "type":"MAIN",
        "sourceType":"ORIGIN"
    },
    {
        "name":"SYSTEM_STOPWORD.dic",
        "type":"STOP",
        "sourceType":"ORIGIN"
    }
]

Sample success responses

XML format

<0>
    <name>deploy_0.dic</name>
    <fileSize>220</fileSize>
    <sourceType>OSS</sourceType>
    <type>MAIN</type>
</0>
<1>
    <name>SYSTEM_MAIN.dic</name>
    <fileSize>2782602</fileSize>
    <sourceType>ORIGIN</sourceType>
    <type>MAIN</type>
</1>
<2>
    <name>SYSTEM_STOPWORD.dic</name>
    <fileSize>132</fileSize>
    <sourceType>ORIGIN</sourceType>
    <type>STOP</type>
</2>

JSON format

[
        {
            "name":"deploy_0.dic",
            "fileSize":220,
            "sourceType":"OSS",
            "type":"MAIN"
        },
        {
            "name":"SYSTEM_MAIN.dic",
            "fileSize":2782602,
            "sourceType":"ORIGIN",
            "type":"MAIN"
        },
        {
            "name":"SYSTEM_STOPWORD.dic",
            "fileSize":132,
            "sourceType":"ORIGIN",
            "type":"STOP"
        }
    ]

Error codes

HTTP status code Error code Error message Description
400 InstanceNotFound The instanceId provided does not exist The error message returned because the specified instance cannot be found. Please check the status of the instance.

For a list of error codes, visit the API Error Center.