Create an index
Run a CLI command to create an index for a specified LogStore. You must create an index before you can use the query or SQL analysis features.
Prerequisites
Before you run the CLI command, make sure that the following requirements are met:
SLS is activated. For more information, see Getting started with Simple Log Service.
The SLS CLI is installed and configured. For more information, see Install the CLI and Configure the CLI.
A project and a LogStore are created. For more information, see Create a project and Create a LogStore.
When you create an index, you must configure at least one of the following: full-text index (line) or field index (keys).
An index takes effect within approximately one minute after creation. The index applies only to newly written data. To apply the index to historical data, you must manually rebuild the index.
Command syntax
aliyun sls create-index --project=<value> --logstore=<value> [--line=<value>] [--keys=<value>]
Parameters
The following table describes the required and command-specific parameters.
Parameter |
Type |
Required |
Example |
Description |
|
String |
Yes |
aliyun-test-project |
The name of the project. |
|
String |
Yes |
aliyun-test-logstore |
The name of the LogStore. |
|
String |
No |
See example |
The full-text index configuration in JSON format. Supports keyword-based searches. Fields include: |
|
String |
No |
See example |
The field index configuration in JSON format. Supports field-based filtering and SQL analysis. Each field includes the following properties: |