Creates the indexes for a specified Logstore.

Request syntax

POST /logstores/<logstoreName>/index HTTP/1.1
Authorization: <AuthorizationString>
x-log-bodyrawsize: <x-log-bodyrawsize>
User-Agent: <User-Agent>
x-log-apiversion: <APIVersion>
Host: <Project Endpoint>
x-log-signaturemethod: hmac-sha1
Date: <GMT Date>
Content-Type: application/json
Content-MD5: <Content-MD5>
Content-Length: <Content-Length>
{
  "line": <full text index>,
  "keys": <key-value index>
}

Request parameters

  • Request headers

    The CreateIndex 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 my-logstore 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
    caseSensitive bool No true Specifies whether the field is case-sensitive.
    chn bool No None. Specifies whether the field contains Chinese characters.
    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.
    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 index The type of the field.
    alias string No None. 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 analytics for the field.

Response parameters

  • Response headers

    The CreateIndex 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
    POST /logstores/my-logstore/index HTTP/1.1
    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:43:16 GMT
    Content-Type: application/json
    Content-MD5: 22876515FC311F857AD6C7902F6A0148
    Content-Length: 316
    Connection: Keep-Alive
    {
      "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 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 IndexAlreadyExist log store index is already created. The error message returned because the specified Logstore index already exists.
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.