KnnVectorQuery

Updated at:

KnnVectorQuery finds the most similar items in a large-scale dataset by performing an approximate nearest neighbor search with a numeric vector.

Data structure

message KnnVectorQuery {
    optional string field_name = 1;
    optional int32 top_k = 2;
    repeated float float32_query_vector = 4;
    optional Query filter = 5;
    optional float weight = 6;
    optional float min_score = 7;
}

Parameter

Type

Required

Description

field_name

string

Yes

The name of the vector field.

top_k

int32

Yes

The number of nearest neighbors to return. For details about the maximum value, see Search Index limits.

float32_query_vector

float

Yes

The query vector for the similarity search.

filter

Query

No

A filter for applying additional, non-vector query conditions.

weight

float

No

The weight of this query condition.

min_score

float

No

The score threshold. Returns only rows with a score greater than this value. The value must be greater than or equal to 0. The default value is 0.