Cria índices para um Logstore especificado.
Sintaxe da solicitação
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>]
Parâmetros da solicitação
A tabela a seguir descreve os parâmetros obrigatórios e específicos do comando create_index.
|
Parâmetro |
Tipo |
Obrigatório |
Exemplo |
Descrição |
|
--project_name |
String |
Sim |
aliyun-test-project |
Nome do projeto. |
|
--logstore_name |
String |
Sim |
logstroe-a |
Nome do Logstore. |
|
--index_detail |
JSON Object |
Sim |
file://./indexdetail.json |
Caminho do arquivo de configuração usado para definir os índices. Para mais informações, consulte Criar índices e GitHub. |
Para obter detalhes sobre os parâmetros globais da interface de linha de comando (CLI) do Simple Log Service, consulte Parâmetros globais.
Exemplos
-
Crie um arquivo chamado indexdetail.json. O exemplo a seguir mostra o conteúdo desse arquivo:
{ "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" ] } } -
Use a conta padrão para criar índices em um Logstore chamado logstore-a. Execute o seguinte comando:
aliyunlog log create_index --project_name="aliyun-test-project" --logstore_name="logstore-a" --index_detail="file://./indexdetail.json" -
Consulte as configurações de índice. Execute o seguinte comando:
aliyunlog log get_index_config --project_name="aliyun-test-project" --logstore_name="logstore-a" --format-output=jsonA saída retornada será semelhante a esta:
{ "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 }
Códigos de erro
Se uma mensagem de erro for retornada, corrija o problema com base nos códigos de erro da operação de API correspondente. Para mais informações, consulte Códigos de erro.