百度智能云

All Product Document

          Log Service

          Index Operations

          Create indexes

          With following codes, create an index for the specified logstore

          createIndexRequest := CreateIndexRequest{
              Project:      "default",
              LogStoreName: "test",
              Fulltext:     true,
              CaseSensitive:  true,
          	Separators:     "",
          	IncludeChinese: true,
              Fields: map[string]api.LogField{
                  "test1": {
                      Type: "float",
                      CaseSensitive:  true,
          			IncludeChinese: true,
                  },
              },
          }
          err := BLS_CLIENT.CreateIndexV2(createIndexRequest)
          if err != nil {
            fmt.Println("Create index failed: ", err)
          } else {
            fmt.Println("Create index success.")
          }

          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

          updateIndexRequest := UpdateIndexRequest{
              Project:      "default",
              LogStoreName: "test",
              Fulltext:     true,
              CaseSensitive:  false,
          	IncludeChinese: true,
          	Separators:     "@&?",
              Fields: map[string]api.LogField{
                  "test1": {
                      Type: "float",
                      CaseSensitive:  true,
          			Separators:     "@?",
          			IncludeChinese: false,
                  },
                  "test2": {
                      Type: "bool",
                      CaseSensitive:  true,
          			Separators:     "",
          			IncludeChinese: false,
                  },
              },
          }
          err := BLS_CLIENT.UpdateIndexV2(updateIndexRequest)
          if err != nil {
            fmt.Println("Update index failed: ", err)
          } else {
            fmt.Println("Update index success.")
          }

          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.

          describeIndexRequest := DescribeIndexRequest{
              Project:      "default",
              LogStoreName: "test",
          }
          res, err := BLS_CLIENT.DescribeIndexV2(describeIndexRequest)
          if err != nil {
            fmt.Println("Get index failed: ", err)
          } else {
            fmt.Println("Index info: ", res)
          }

          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.

          deleteIndexRequest := DeleteIndexRequest{
              Project:      "default",
              LogStoreName: "test",
          }
          err := BLS_CLIENT.DeleteIndexV2(deleteIndexRequest)
          if err != nil {
            fmt.Println("Delete index failed: ", err)
          } else {
            fmt.Println("Delete index success.")
          }

          Prompt:

          • Detailed parameter configuration and restrictions may refer to BLS API document DeleteIndex
          Previous
          FastQuery Operations
          Next
          LogRecord Operations