Skip to main content

Indexes

The struct types on this page implement the method signatures of the entity.Index interface.

entity.GenericIndex

This struct type applies to general purposes without any constraint on the index type. You can use entity.NewGenericIndex() to create one for the client.CreateIndex() request as follows:

index := entity.NewGenericIndex(name string, it entity.IndexType, params map[string]string)

Parameter

Description

Type

name

Name of the index.

string

it

Type of the index.

entity.IndexType

params

Index parameters corresponding to the specified index type.

map[string]string

entity.IndexAUTOINDEX

This struct type creates an AUTOINDEX for the specified field. You can use entity.NewIndexAUTOINDEX() to create one for the client.CreateIndex() request as follows:

index := entity.NewIndexAUTOINDEX(metricType MetricType)

Parameter

Description

Type

metricType

Metric type for Milvus to follow when it measures similarities between vector embeddings.

entity.MetricType

entity.IndexBinFlat

This struct type creates a BIN_FLAT index for the specified field. You can use entity.NewIndexBinFlat() to create one for the client.CreateIndex() request as follows:

index := entity.NewIndexBinFlat(metricType MetricType, nlist int)

Parameter

Description

Type

Value Range

metricType

Metric type for Milvus to follow when it measures similarities between vector embeddings.

entity.MetricType

N/A

nlist

Number of cluster units.

int

[1, 65536]

entity.IndexBinIvfFlat

This struct type creates a BIN_IVF_FLAT index for the specified field. You can use entity.NewIndexBinIvfFlat() to create one for the client.CreateIndex() request as follows:

index := entity.NewIndexBinIvfFlat(metricType MetricType, nlist int)

Parameter

Description

Type

Value Range

metricType

Metric type for Milvus to follow when it measures similarities between vector embeddings.

entity.MetricType

N/A

nlist

Number of cluster units.

int

[1, 65536]

entity.IndexDISKANN

This struct type creates a DiskANN index for the specified field. You can use entity.NewIndexDISKANN() to create one for the client.CreateIndex() request as follows:

index := entity.NewIndexDISKANN(metricType MetricType)

Parameter

Description

Type

metricType

Metric type for Milvus to follow when it measures similarities between vector embeddings.

entity.MetricType

entity.IndexFlat

This struct type creates a FLAT index for the specified field. You can use entity.NewIndexIvfFlat() to create one for the client.CreateIndex() request as follows:

index := entity.NewIndexFlat(metricType MetricType)

Parameter

Description

Type

metricType

Metric type for Milvus to follow when it measures similarities between vector embeddings.

entity.MetricType

entity.IndexGPUBruteForce

This struct type creates a GPU_BRUTE_FORCE index for the specified field. You can use entity.NewIndexGPUBruteForce() to create one for the client.CreateIndex() request as follows:

index := entity.NewIndexGPUBruteForce(metricType MetricType)

Parameter

Description

Type

metricType

Metric type for Milvus to follow when it measures similarities between vector embeddings.

entity.MetricType

entity.IndexGPUCagra

This struct type creates a GPU_CAGRA index for the specified field. You can use entity.NewIndexGPUCagra() to create one for the client.CreateIndex() request as follows:

index := entity.NewIndexBinIvfFlat(metricType MetricType, intermediateGraphDegree, graphDegree int)

Parameter

Description

Type

Value Range

metricType

Metric type for Milvus to follow when it measures similarities between vector embeddings.

entity.MetricType

N/A

intermediateGraphDegree

Number of k-nearest neighbors (k) of this intermediate k-NN graph, trade off the quality of the final searchable CAGRA graph;

It affects recall and build time by determining the graph's degree before pruning. Recommended values are 32 or 64.

int

graphDegree

CAGRA's optimized graph fixed-degree number.

It affects search performance and recall by setting the graph's degree after pruning. A larger difference between these two degrees results in a longer build time. Its value must be smaller than the value of intermediateGraphDegree.

int

entity.IndexGPUIvfFlat

This struct type creates a GPU_IVF_FLAT index for the specified field. You can use entity.NewIndexGPUIvfFlat() to create one for the client.CreateIndex() request as follows:

index := entity.NewIndexGPUIvfFlat(metricType MetricType, nlist int)

Parameter

Description

Type

Value Range

metricType

Metric type for Milvus to follow when it measures similarities between vector embeddings.

entity.MetricType

N/A

nlist

Number of cluster units.

int

[1, 65536]

entity.IndexGPUIvfPQ

This struct type creates a GPU_IVF_PQ index for the specified field. You can use entity.NewIndexGPUIvfPQ() to create one for the client.CreateIndex() request as follows:

index := entity.NewIndexGPUIvfPQ(metricType MetricType, nlist int, m int, nbits int)

Parameter

Description

Type

Value Range

metricType

Metric type for Milvus to follow when it measures similarities between vector embeddings.

entity.MetricType

N/A

nlist

Number of cluster units.

int

[1, 65536]

m

Number of factors of product quantization

int

dim mod m or = 0

nbits

Number of bits in which each low-dimensional vector is stored.

int

[1, 16]

entity.IndexHNSW

This struct type creates an HNSW index for the specified field. You can use entity.NewIndexHNSW() to create one for the client.CreateIndex() request as follows:

index := entity.NewIndexHNSW(metricType MetricType, M int, efConstruction int)

Parameter

Description

Type

Value Range

metricType

Metric type for Milvus to follow when it measures similarities between vector embeddings.

entity.MetricType

N/A

M

Maximum number of outgoing connections in the graph. Higher M leads to higher accuracy/run_time at fixed ef/efConstruction.

int

[2, 2048]

efConstruction

Index search speed/build speed tradeoff. Increasing this parameter may enhance index quality, but it also tends to lengthen the indexing time.

int

[1, int_max]

entity.IndexIvfFlat

This struct type creates an IVF_FLAT index for the specified field. You can use entity.NewIndexIvfFlat() to create one for the client.CreateIndex() request as follows:

index := entity.NewIndexIvfFlat(metricType MetricType, nlist int)

Parameter

Description

Type

Value Range

metricType

Metric type for Milvus to follow when it measures similarities between vector embeddings.

entity.MetricType

N/A

nlist

Number of cluster units.

int

[1, 65536]

In addition to the methods defined in the entity.Index interface, this struct type also defines the following methods.

Method

Return Type

Description

SupportBinary()

bool

Returns whether

entity.IndexIvfPQ

This struct type creates an IVF_PQ index for the specified field. You can use entity.NewIndexGPUIvfPQ() to create one for the client.CreateIndex() request as follows:

index := entity.NewIndexIvfPQ(metricType MetricType, nlist int, m int, nbits int)

Parameter

Description

Type

Value Range

metricType

Metric type for Milvus to follow when it measures similarities between vector embeddings.

entity.MetricType

N/A

nlist

Number of cluster units.

int

[1, 65536]

m

Number of factors of product quantization

int

dim mod m or = 0

nbits

Number of bits in which each low-dimensional vector is stored.

int

[1, 16]

entity.IndexIvfSQ8

This struct type creates an IVF_SQ8 index for the specified field. You can use entity.NewIndexIvfSQ8() to create one for the client.CreateIndex() request as follows:

index := entity.NewIndexIvfSQ8(metricType MetricType, nlist int)

Parameter

Description

Type

Value Range

metricType

Metric type for Milvus to follow when it measures similarities between vector embeddings.

entity.MetricType

N/A

nlist

Number of cluster units.

int

[1, 65536]

entity.IndexSCANN

This struct type creates a SCANN index for the specified field. You can use entity.NewIndexSCANN() to create one for the client.CreateIndex() request as follows:

index := entity.NewIndexSCANN(metricType MetricType, nlist int, with_raw_data bool)

Parameter

Description

Type

Value Range

metricType

Metric type for Milvus to follow when it measures similarities between vector embeddings.

entity.MetricType

N/A

nlist

Number of cluster units.

int

[1, 65536]

with_raw_data

Whether to include raw data when creating the index.

bool

N/A

entity.IndexSparseInverted

This struct type creates a SPARSE_INVERTED_INDEX index for the specified field. You can use entity.NewIndexSparseInverted() to create one for the client.CreateIndex() request as follows:

index := entity.NewIndexSparseInverted(metricType MetricType, dropRatio float64)

Parameter

Description

Type

Value Range

metricType

Metric type for Milvus to follow when it measures similarities between vector embeddings.

entity.MetricType

N/A

dropRatio

Proportion of small vector values that are excluded during the indexing process. This option allows fine-tuning of the indexing process, making a trade-off between efficiency and accuracy by disregarding small values when building the index.

float64

[0, 1]

entity.IndexSparseWAND

This struct type creates a SPARSE_WAND index for the specified field. You can use entity.NewIndexSparseWAND() to create one for the client.CreateIndex() request as follows:

index := entity.NewIndexSparseWAND(metricType MetricType, dropRatio float64)

Parameter

Description

Type

Value Range

metricType

Metric type for Milvus to follow when it measures similarities between vector embeddings.

entity.MetricType

N/A

dropRatio

Proportion of small vector values that are excluded during the indexing process. This option allows fine-tuning of the indexing process, making a trade-off between efficiency and accuracy by disregarding small values when building the index.

float64

[0, 1]

entity.IndexType

This string type defines all applicable index types.

const (
Flat IndexType = "FLAT" //faiss
BinFlat IndexType = "BIN_FLAT"
IvfFlat IndexType = "IVF_FLAT" //faiss
BinIvfFlat IndexType = "BIN_IVF_FLAT"
IvfPQ IndexType = "IVF_PQ" //faiss
IvfSQ8 IndexType = "IVF_SQ8"
HNSW IndexType = "HNSW"
AUTOINDEX IndexType = "AUTOINDEX"
DISKANN IndexType = "DISKANN"
SCANN IndexType = "SCANN"

GPUIvfFlat IndexType = "GPU_IVF_FLAT"
GPUIvfPQ IndexType = "GPU_IVF_PQ"

GPUCagra IndexType = "GPU_CAGRA"
GPUBruteForce IndexType = "GPU_BRUTE_FORCE"

// Sparse
SparseInverted IndexType = "SPARSE_INVERTED_INDEX"
SparseWAND IndexType = "SPARSE_WAND"

// DEPRECATED
Scalar IndexType = ""

Trie IndexType = "Trie"
Sorted IndexType = "STL_SORT"
Inverted IndexType = "INVERTED"
)