Modifies the indexes for a specified Logstore.
Request syntax
PUT /logstores/<logstoreName>/index HTTP/1.1
Authorization: <AuthorizationString>
x-log-bodyrawsize: 0
User-Agent: <UserAgent>
x-log-apiversion: 0.6.0
Host: <Project Endpoint>
x-log-signaturemethod: hmac-sha1
Date: <GMT Date>
Content-Type: application/json
Content-MD5: <Content-MD5>
Content-Length: <ContentLength>
{
"line": <full text index>,
"keys": <key-value index>,
}
Request parameters
- Request headers
The UpdateIndex operation does not have operation-specific request headers. For information about the common request headers of Log Service API operations, see Common request headers.
- Parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
logstoreName | string | Yes | logstore-4 | The name of the Logstore. |
keys | object | No | None. | The field search configuration. It contains one or more key-value indexes, where the key is the field name and the value is the field value. |
line | object | No | None. | The full-text index configuration. |
You must specify the keys parameter, the line parameter, or both. The following table describes the full-text index configuration.
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
token | array | Yes | ["\n", "\t","\r"] | The list of delimiters. A delimiter can be set to specify the method in which a value is delimited. For more information about the delimiters, see the sample request. |
caseSensitive | bool | No | true | Specifies whether the field is case-sensitive. |
chn | bool | No | None. | Specifies whether the field contains Chinese characters. |
include_keys | array | No | None. | The list of included fields. This parameter and the exclude_keys parameter cannot be specified at the same time. |
exclude_keys | array | No | None. | The list of excluded fields. This parameter and the include_keys parameter cannot be specified at the same time. |
The following table describes the field search configuration.
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
type | string | Yes | text | The type of the field. |
alias | string | No | agent_alias | The alias of the field. |
chn | bool | No | None. | Specifies whether the field contains Chinese characters. This parameter takes effect only when the value of the type parameter is text. |
token | array | No. This parameter is required only when the value of the type parameter is text. | ["\n", "\t","\r"] | The list of delimiters. This parameter takes effect only when the value of the type parameter is text. |
caseSensitive | bool | No | true | Specifies whether the field is case-sensitive. This parameter takes effect only when the value of the type parameter is text. |
doc_value | bool | No | true | Specifies whether to enable the analytics feature for the field. |
Response parameters
- Response headers
The UpdateIndex operation does not have operation-specific response headers. For information about the common response headers of Log Service API operations, see Common response headers.
- Response elements
The HTTP status code 200 is returned.
Examples
- Sample requests
PUT /logstores/logstore-4/index HTTP/1.1 Header: Authorization: LOG <yourAccessKeyId>:<yourSignature> x-log-bodyrawsize: 0 User-Agent: sls-java-sdk-v-0.6.1 x-log-apiversion: 0.6.0 Host: my-project.cn-shanghai.log.aliyuncs.com x-log-signaturemethod: hmac-sha1 Date: Mon, 07 May 2018 09:47:20 GMT Content-Type: application/json Content-MD5: 1860B805A6AA5288B97B32CF3B519112 Content-Length: 316 Connection: Keep-Alive Body: { "line": { "token": [ ",", " ", "'", "\", ";", "=", "(", ")", "[", "]", "{", "}", "?", "@", "&", "<", ">", "/", ":", "\n", "\t", "\r" ] }, "keys": { "agent": { "doc_value": true, "caseSensitive": true, "alias": "agent_alias", "type": "text", "token": [ ",", " ", "'", "\"", ";", "=", "(", ")", "[", "]", "{", "}", "?", "@", "&", "<", ">", "/", ":", "\n", "\t", "\r" ] } } }
- Sample success responses
HTTP/1.1 200 Server: nginx/1.12.1 Content-Length: 0 Connection: close Access-Control-Allow-Origin: * Date: Mon, 07 May 2018 09:47:21 GMT x-log-requestid: 5AF020A98CBAA2EF52AB66C9
Error codes
HTTP status code | Error code | Error message | Description |
---|---|---|---|
400 | ParameterInvalid | log store index is not created. | The error message returned because no indexes were created for the specified Logstore. |
400 | ParameterInvalid | key config must has type. | The error message returned because the type must be specified for the key configurations. |
400 | IndexInfoInvalid | required field token is lacking or of error format. | The error message returned because the required field tags are not specified or their formats are invalid. |
400 | IndexInfoInvalid | required fields line/keys are lacking or of error format. | The error message returned because the required fields, lines or keys are not specified or their formats are invalid. |
404 | ProjectNotExist | The Project does not exist : {Project}. | The error message returned because the specified project does not exist. |
404 | LogStoreNotExist | logstore {logstoreName} dose not exist. | The error message returned because the specified Logstore does not exist. |
500 | InternalServerError | Specified Server Error Message. | The error message returned because an internal server error has occurred. |
For more information about the error codes, see Common error codes.