Reference documentation and code samples for the Vector Search V1 API class Google::Cloud::VectorSearch::V1::VectorSearch.
Defines a search operation using a query vector.
Inherits
- Object
Extended By
- Google::Protobuf::MessageExts::ClassMethods
Includes
- Google::Protobuf::MessageExts
Methods
#distance_metric
def distance_metric() -> ::Google::Cloud::VectorSearch::V1::DistanceMetric- (::Google::Cloud::VectorSearch::V1::DistanceMetric) — Optional. The distance metric to use for the KNN search. If not specified, DOT_PRODUCT will be used as the default.
#distance_metric=
def distance_metric=(value) -> ::Google::Cloud::VectorSearch::V1::DistanceMetric- value (::Google::Cloud::VectorSearch::V1::DistanceMetric) — Optional. The distance metric to use for the KNN search. If not specified, DOT_PRODUCT will be used as the default.
- (::Google::Cloud::VectorSearch::V1::DistanceMetric) — Optional. The distance metric to use for the KNN search. If not specified, DOT_PRODUCT will be used as the default.
#filter
def filter() -> ::Google::Protobuf::Struct-
(::Google::Protobuf::Struct) — Optional. A JSON filter expression, e.g.
{"genre": {"$eq": "sci-fi"}}, represented as agoogle.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:$andor$orwith a list of filters, or$notwith one filter. Field operators and their values:$eqand$netake a string, number or bool;$lt,$lte,$gtand$gtetake a number;$in,$ninand$alltake a list of strings;$existstakes a bool. Several keys in one object (implicit AND) and implicit equality ({"genre": "sci-fi"}) are rejected; use$andand$eqinstead.Logical operators can be nested at most 2 levels deep, e.g.
{"$and": [{"$or": [{"a": {"$eq": 1}}, {"b": {"$eq": 2}}]}]}. Deeper filters are rejected withINVALID_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 viasearch_hint.index_hint), every filtered field must be listed inIndex.filter_fieldsat index creation,$orand$allare accepted only at the top level of the filter, and$notand$existsare not supported. Not every unsupported filter is rejected: most produceINVALID_ARGUMENT, but some are silently ignored, so do not rely on the error. If no ready index exists onsearch_field, or ifsearch_hint.knn_hintis set, the search is served by K-Nearest Neighbor (KNN) search, which has none of these filter restrictions.
#filter=
def filter=(value) -> ::Google::Protobuf::Struct-
value (::Google::Protobuf::Struct) — Optional. A JSON filter expression, e.g.
{"genre": {"$eq": "sci-fi"}}, represented as agoogle.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:$andor$orwith a list of filters, or$notwith one filter. Field operators and their values:$eqand$netake a string, number or bool;$lt,$lte,$gtand$gtetake a number;$in,$ninand$alltake a list of strings;$existstakes a bool. Several keys in one object (implicit AND) and implicit equality ({"genre": "sci-fi"}) are rejected; use$andand$eqinstead.Logical operators can be nested at most 2 levels deep, e.g.
{"$and": [{"$or": [{"a": {"$eq": 1}}, {"b": {"$eq": 2}}]}]}. Deeper filters are rejected withINVALID_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 viasearch_hint.index_hint), every filtered field must be listed inIndex.filter_fieldsat index creation,$orand$allare accepted only at the top level of the filter, and$notand$existsare not supported. Not every unsupported filter is rejected: most produceINVALID_ARGUMENT, but some are silently ignored, so do not rely on the error. If no ready index exists onsearch_field, or ifsearch_hint.knn_hintis set, the search is served by K-Nearest Neighbor (KNN) search, which has none of these filter restrictions.
-
(::Google::Protobuf::Struct) — Optional. A JSON filter expression, e.g.
{"genre": {"$eq": "sci-fi"}}, represented as agoogle.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:$andor$orwith a list of filters, or$notwith one filter. Field operators and their values:$eqand$netake a string, number or bool;$lt,$lte,$gtand$gtetake a number;$in,$ninand$alltake a list of strings;$existstakes a bool. Several keys in one object (implicit AND) and implicit equality ({"genre": "sci-fi"}) are rejected; use$andand$eqinstead.Logical operators can be nested at most 2 levels deep, e.g.
{"$and": [{"$or": [{"a": {"$eq": 1}}, {"b": {"$eq": 2}}]}]}. Deeper filters are rejected withINVALID_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 viasearch_hint.index_hint), every filtered field must be listed inIndex.filter_fieldsat index creation,$orand$allare accepted only at the top level of the filter, and$notand$existsare not supported. Not every unsupported filter is rejected: most produceINVALID_ARGUMENT, but some are silently ignored, so do not rely on the error. If no ready index exists onsearch_field, or ifsearch_hint.knn_hintis set, the search is served by K-Nearest Neighbor (KNN) search, which has none of these filter restrictions.
#output_fields
def output_fields() -> ::Google::Cloud::VectorSearch::V1::OutputFields- (::Google::Cloud::VectorSearch::V1::OutputFields) — Optional. Mask specifying which fields to return.
#output_fields=
def output_fields=(value) -> ::Google::Cloud::VectorSearch::V1::OutputFields- value (::Google::Cloud::VectorSearch::V1::OutputFields) — Optional. Mask specifying which fields to return.
- (::Google::Cloud::VectorSearch::V1::OutputFields) — Optional. Mask specifying which fields to return.
#search_field
def search_field() -> ::String- (::String) — Required. The vector field to search.
#search_field=
def search_field=(value) -> ::String- value (::String) — Required. The vector field to search.
- (::String) — Required. The vector field to search.
#search_hint
def search_hint() -> ::Google::Cloud::VectorSearch::V1::SearchHint- (::Google::Cloud::VectorSearch::V1::SearchHint) — 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.
#search_hint=
def search_hint=(value) -> ::Google::Cloud::VectorSearch::V1::SearchHint- value (::Google::Cloud::VectorSearch::V1::SearchHint) — 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.
- (::Google::Cloud::VectorSearch::V1::SearchHint) — 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.
#sparse_vector
def sparse_vector() -> ::Google::Cloud::VectorSearch::V1::SparseVector-
(::Google::Cloud::VectorSearch::V1::SparseVector) — A sparse vector for the query.
Note: The following fields are mutually exclusive:
sparse_vector,vector. If a field in that set is populated, all other fields in the set will automatically be cleared.
#sparse_vector=
def sparse_vector=(value) -> ::Google::Cloud::VectorSearch::V1::SparseVector-
value (::Google::Cloud::VectorSearch::V1::SparseVector) — A sparse vector for the query.
Note: The following fields are mutually exclusive:
sparse_vector,vector. If a field in that set is populated, all other fields in the set will automatically be cleared.
-
(::Google::Cloud::VectorSearch::V1::SparseVector) — A sparse vector for the query.
Note: The following fields are mutually exclusive:
sparse_vector,vector. If a field in that set is populated, all other fields in the set will automatically be cleared.
#top_k
def top_k() -> ::Integer- (::Integer) — Optional. The number of nearest neighbors to return.
#top_k=
def top_k=(value) -> ::Integer- value (::Integer) — Optional. The number of nearest neighbors to return.
- (::Integer) — Optional. The number of nearest neighbors to return.
#vector
def vector() -> ::Google::Cloud::VectorSearch::V1::DenseVector-
(::Google::Cloud::VectorSearch::V1::DenseVector) — A dense vector for the query.
Note: The following fields are mutually exclusive:
vector,sparse_vector. If a field in that set is populated, all other fields in the set will automatically be cleared.
#vector=
def vector=(value) -> ::Google::Cloud::VectorSearch::V1::DenseVector-
value (::Google::Cloud::VectorSearch::V1::DenseVector) — A dense vector for the query.
Note: The following fields are mutually exclusive:
vector,sparse_vector. If a field in that set is populated, all other fields in the set will automatically be cleared.
-
(::Google::Cloud::VectorSearch::V1::DenseVector) — A dense vector for the query.
Note: The following fields are mutually exclusive:
vector,sparse_vector. If a field in that set is populated, all other fields in the set will automatically be cleared.