NewJSONPathIndex()
This function creates a JSON path scalar index for a field nested inside a JSON document.
func NewJSONPathIndex(indexType IndexType, jsonCastType string, jsonPath string) *JSONPathIndex
PARAMETERS:
-
indexType (IndexType)
The scalar index type to apply to the JSON path, e.g.,
InvertedorSorted. -
jsonCastType (string)
The type used to interpret the value at the JSON path, e.g.,
int64,float,varchar. -
jsonPath (string)
The path to the target field within the JSON document.
RETURNS:
An index configuration instance. Pass this to CreateIndex() via the index option.
BUILDER METHODS:
-
WithIndexName(name string) *JSONPathIndexSets the name of the index.
Example
import (
"github.com/milvus-io/milvus/client/v3/index"
"github.com/milvus-io/milvus/client/v3/milvusclient"
)
// Create index configuration for a JSON path
idx := index.NewJSONPathIndex(index.Inverted, "varchar", "metadata.category").WithIndexName("category_idx")
// Use with CreateIndex
createIdxOption := milvusclient.NewCreateIndexOption("collection_name", "metadata", idx)
task, err := client.CreateIndex(ctx, createIdxOption)