Vector Search v1 API - Class VectorSearch (1.3.0)

public sealed class VectorSearch : IMessage<VectorSearch>, IEquatable<VectorSearch>, IDeepCloneable<VectorSearch>, IBufferMessage, IMessage

Reference documentation and code samples for the Vector Search v1 API class VectorSearch.

Defines a search operation using a query vector.

Inheritance

object > VectorSearch

Namespace

Google.Cloud.VectorSearch.V1

Assembly

Google.Cloud.VectorSearch.V1.dll

Constructors

VectorSearch()

public VectorSearch()

VectorSearch(VectorSearch)

public VectorSearch(VectorSearch other)
Parameter
Name Description
other VectorSearch

Properties

DistanceMetric

public DistanceMetric DistanceMetric { get; set; }

Optional. The distance metric to use for the KNN search. If not specified, DOT_PRODUCT will be used as the default.

Property Value
Type Description
DistanceMetric

Filter

public Struct Filter { get; set; }

Optional. A JSON filter expression, e.g. {"genre": {"$eq": "sci-fi"}}, represented as a google.protobuf.Struct.

An empty filter ({}) matches all data objects. Otherwise, each JSON object in the filter must have exactly one key: either a field name mapped to one operator ({"price": {"$lt": 100}}), or a logical operator: $and or $or with a list of filters, or $not with one filter. Field operators and their values: $eq and $ne take a string, number or bool; $lt, $lte, $gt and $gte take a number; $in, $nin and $all take a list of strings; $exists takes a bool. Several keys in one object (implicit AND) and implicit equality ({"genre": "sci-fi"}) are rejected; use $and and $eq instead.

Logical operators can be nested at most 2 levels deep, e.g. {"$and": [{"$or": [{"a": {"$eq": 1}}, {"b": {"$eq": 2}}]}]}. Deeper filters are rejected with INVALID_ARGUMENT.

Which filters are accepted depends on how the search is served. If it is served by an approximate nearest neighbor (ANN) index (by default when a ready index exists on search_field, or when one is selected via search_hint.index_hint), every filtered field must be listed in Index.filter_fields at index creation, $or and $all are accepted only at the top level of the filter, and $not and $exists are not supported. Not every unsupported filter is rejected: most produce INVALID_ARGUMENT, but some are silently ignored, so do not rely on the error. If no ready index exists on search_field, or if search_hint.knn_hint is set, the search is served by K-Nearest Neighbor (KNN) search, which has none of these filter restrictions.

Property Value
Type Description
Struct

HasTopK

public bool HasTopK { get; }

Gets whether the "top_k" field is set

Property Value
Type Description
bool

OutputFields

public OutputFields OutputFields { get; set; }

Optional. Mask specifying which fields to return.

Property Value
Type Description
OutputFields

SearchField

public string SearchField { get; set; }

Required. The vector field to search.

Property Value
Type Description
string

SearchHint

public SearchHint SearchHint { get; set; }

Optional. Sets the search hint. If no strategy is specified, the service will use an index if one is available, and fall back to the default KNN search otherwise.

Property Value
Type Description
SearchHint

SparseVector

public SparseVector SparseVector { get; set; }

A sparse vector for the query.

Property Value
Type Description
SparseVector

TopK

public int TopK { get; set; }

Optional. The number of nearest neighbors to return.

Property Value
Type Description
int

Vector

public DenseVector Vector { get; set; }

A dense vector for the query.

Property Value
Type Description
DenseVector

VectorTypeCase

public VectorSearch.VectorTypeOneofCase VectorTypeCase { get; }
Property Value
Type Description
VectorSearchVectorTypeOneofCase