全部产品
Search
文档中心

Simple Log Service:create_index

更新时间:Jul 06, 2025

Membuat indeks untuk Logstore yang ditentukan.

Sintaks permintaan

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

Parameter permintaan

Tabel berikut menjelaskan parameter yang diperlukan dan spesifik dari perintah create_index.

Parameter

Tipe

Diperlukan

Contoh

Deskripsi

--project_name

String

Ya

aliyun-test-project

Nama dari proyek.

--logstore_name

String

Ya

logstroe-a

Nama dari Logstore.

--index_detail

Objek JSON

Ya

file://./indexdetail.json

Path file konfigurasi yang digunakan untuk mengonfigurasi indeks. Untuk informasi lebih lanjut, lihat Buat indeks dan GitHub.

Untuk informasi tentang parameter global dari antarmuka baris perintah (CLI) Simple Log Service, lihat Parameter Global.

Contoh

  1. Buat file bernama indexdetail.json. Contoh berikut menunjukkan isi dari file indexdetail.json:

    {
      "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. Gunakan akun default untuk membuat indeks untuk Logstore bernama logstore-a. Jalankan perintah berikut:

    aliyunlog log create_index --project_name="aliyun-test-project" --logstore_name="logstore-a" --index_detail="file://./indexdetail.json"
  3. Kueri pengaturan indeks. Jalankan perintah berikut:

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

    Keluaran berikut dikembalikan:

    {
      "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
    }

Kode kesalahan

Jika pesan kesalahan dikembalikan, perbaiki kesalahan berdasarkan kode kesalahan dari operasi API terkait. Untuk informasi lebih lanjut, lihat Kode Kesalahan.

Referensi API

CreateIndex