create_index

Updated at: 2024-10-15 10:05

Creates indexes for a specified Logstore.

Request syntax

aliyunlog log create_index --project_name=<value> --logstore_name=<value> --index_detail=<value> [--access-id=<value>] [--access-key=<value>] [--sts-token=<value>] [--region-endpoint=<value>] [--client-name=<value>] [--jmes-filter=<value>] [--format-output=<value>] [--decode-output=<value>]

Request parameters

The following table describes the required and specific parameters of the create_index command.

Parameter

Type

Required

Example

Description

Parameter

Type

Required

Example

Description

--project_name

String

Yes

aliyun-test-project

The name of the project.

--logstore_name

String

Yes

logstroe-a

The name of the Logstore.

--index_detail

JSON Object

Yes

file://./indexdetail.json

The path of the configuration file that is used to configure indexes. For more information, see Create indexes and GitHub.

For information about the global parameters of the Simple Log Service command-line interface (CLI), see Global parameters.

Examples

  1. Create a file named indexdetail.json. The following example shows the content of the indexdetail.json file:

    {
      "keys": {
        "key1": {
          "caseSensitive": false,
          "token": [
            ",",
            " ",
            "'",
            "\"",
            ";",
            "=",
            "(",
            ")",
            "[",
            "]",
            "{",
            "}",
            "?",
            "@",
            "&",
            "<",
            ">",
            "/",
            ":",
            "\n",
            "\t"
          ],
          "type": "text",
          "doc_value": true
        },
        "key2": {
          "caseSensitive": false,
          "token": [
            ",",
            " ",
            "'",
            "\"",
            ";",
            "=",
            "(",
            ")",
            "[",
            "]",
            "{",
            "}",
            "?",
            "@",
            "&",
            "<",
            ">",
            "/",
            ":",
            "\n",
            "\t"
          ],
          "type": "text",
          "doc_value": true
        },
        "key3": {
          "caseSensitive": false,
          "token": [
            ",",
            " ",
            "'",
            "\"",
            ";",
            "=",
            "(",
            ")",
            "[",
            "]",
            "{",
            "}",
            "?",
            "@",
            "&",
            "<",
            ">",
            "/",
            ":",
            "\n",
            "\t"
          ],
          "type": "text",
          "doc_value": true
        },
        "key4": {
          "caseSensitive": false,
          "token": [
            ",",
            " ",
            "'",
            "\"",
            ";",
            "=",
            "(",
            ")",
            "[",
            "]",
            "{",
            "}",
            "?",
            "@",
            "&",
            "<",
            ">",
            "/",
            ":",
            "\n",
            "\t"
          ],
          "type": "text",
          "doc_value": true
        }
      },
      "storage": "pg",
      "ttl": 2,
      "index_mode": "v2",
      "line": {
        "caseSensitive": false,
        "token": [
          ",",
          " ",
          "'",
          "\"",
          ";",
          "=",
          "(",
          ")",
          "[",
          "]",
          "{",
          "}",
          "?",
          "@",
          "&",
          "<",
          ">",
          "/",
          ":",
          "\n",
          "\t"
        ]
      }
    }
  2. Use the default account to create indexes for a Logstore named logstore-a. Run the following command:

    aliyunlog log create_index --project_name="aliyun-test-project" --logstore_name="logstore-a" --index_detail="file://./indexdetail.json"
  3. Query index settings. Run the following command:

    aliyunlog log get_index_config --project_name="aliyun-test-project" --logstore_name="logstore-a" --format-output=json

    The following output is returned:

    {
      "index_mode": "v2",
      "keys": {
        "key1": {
          "caseSensitive": false,
          "doc_value": true,
          "token": [
            ",",
            " ",
            "'",
            "\"",
            ";",
            "=",
            "(",
            ")",
            "[",
            "]",
            "{",
            "}",
            "?",
            "@",
            "&",
            "<",
            ">",
            "/",
            ":",
            "\n",
            "\t"
          ],
          "type": "text"
        },
        "key2": {
          "caseSensitive": false,
          "doc_value": true,
          "token": [
            ",",
            " ",
            "'",
            "\"",
            ";",
            "=",
            "(",
            ")",
            "[",
            "]",
            "{",
            "}",
            "?",
            "@",
            "&",
            "<",
            ">",
            "/",
            ":",
            "\n",
            "\t"
          ],
          "type": "text"
        },
        "key3": {
          "caseSensitive": false,
          "doc_value": true,
          "token": [
            ",",
            " ",
            "'",
            "\"",
            ";",
            "=",
            "(",
            ")",
            "[",
            "]",
            "{",
            "}",
            "?",
            "@",
            "&",
            "<",
            ">",
            "/",
            ":",
            "\n",
            "\t"
          ],
          "type": "text"
        },
        "key4": {
          "caseSensitive": false,
          "doc_value": true,
          "token": [
            ",",
            " ",
            "'",
            "\"",
            ";",
            "=",
            "(",
            ")",
            "[",
            "]",
            "{",
            "}",
            "?",
            "@",
            "&",
            "<",
            ">",
            "/",
            ":",
            "\n",
            "\t"
          ],
          "type": "text"
        }
      },
      "lastModifyTime": 0,
      "line": {
        "caseSensitive": false,
        "chn": false,
        "token": [
          ",",
          " ",
          "'",
          "\"",
          ";",
          "=",
          "(",
          ")",
          "[",
          "]",
          "{",
          "}",
          "?",
          "@",
          "&",
          "<",
          ">",
          "/",
          ":",
          "\n",
          "\t"
        ]
      },
      "storage": "pg",
      "ttl": 30
    }

Error codes

If an error message is returned, fix the error based on the error codes of the related API operation. For more information, see Error codes.

API reference

CreateIndex

  • On this page (1)
  • Request syntax
  • Request parameters
  • Examples
  • Error codes
  • API reference
Feedback
phone Contact Us

Chat now with Alibaba Cloud Customer Service to assist you in finding the right products and services to meet your needs.

alicare alicarealicarealicare