Index Operations
Updated at:2025-11-03
Create indexes
With following codes, create an index for the specified logstore
Go
1createIndexRequest := CreateIndexRequest{
2 Project: "default",
3 LogStoreName: "test",
4 Fulltext: true,
5 CaseSensitive: true,
6 Separators: "",
7 IncludeChinese: true,
8 Fields: map[string]api.LogField{
9 "test1": {
10 Type: "float",
11 CaseSensitive: true,
12 IncludeChinese: true,
13 },
14 },
15}
16err := BLS_CLIENT.CreateIndexV2(createIndexRequest)
17if err != nil {
18 fmt.Println("Create index failed: ", err)
19} else {
20 fmt.Println("Create index success.")
21}
Prompt:
- Detailed parameter configuration and restrictions may refer to BLS API document Create Index
Update the specified index
With following codes, update the index structure of the specified logstore
Go
1updateIndexRequest := UpdateIndexRequest{
2 Project: "default",
3 LogStoreName: "test",
4 Fulltext: true,
5 CaseSensitive: false,
6 IncludeChinese: true,
7 Separators: "@&?",
8 Fields: map[string]api.LogField{
9 "test1": {
10 Type: "float",
11 CaseSensitive: true,
12 Separators: "@?",
13 IncludeChinese: false,
14 },
15 "test2": {
16 Type: "bool",
17 CaseSensitive: true,
18 Separators: "",
19 IncludeChinese: false,
20 },
21 },
22}
23err := BLS_CLIENT.UpdateIndexV2(updateIndexRequest)
24if err != nil {
25 fmt.Println("Update index failed: ", err)
26} else {
27 fmt.Println("Update index success.")
28}
Prompt:
- Detailed parameter configuration and restrictions may refer to BLS API document Update Index
Get the specified index
Use the following code to obtain the index structure of the specified logstore.
Go
1describeIndexRequest := DescribeIndexRequest{
2 Project: "default",
3 LogStoreName: "test",
4}
5res, err := BLS_CLIENT.DescribeIndexV2(describeIndexRequest)
6if err != nil {
7 fmt.Println("Get index failed: ", err)
8} else {
9 fmt.Println("Index info: ", res)
10}
Prompt:
- Detailed parameter configuration and restrictions may refer to BLS API document Describe Index
Delete the specified index
With following codes, delete the index of the specified logstore, which can empty the index data.
Go
1deleteIndexRequest := DeleteIndexRequest{
2 Project: "default",
3 LogStoreName: "test",
4}
5err := BLS_CLIENT.DeleteIndexV2(deleteIndexRequest)
6if err != nil {
7 fmt.Println("Delete index failed: ", err)
8} else {
9 fmt.Println("Delete index success.")
10}
Prompt:
- Detailed parameter configuration and restrictions may refer to BLS API document DeleteIndex
