Vector Search V1 API - Class Google::Cloud::VectorSearch::V1::VectorSearch (v0.6.0)

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
Returns

#distance_metric=

def distance_metric=(value) -> ::Google::Cloud::VectorSearch::V1::DistanceMetric
Parameter
Returns

#filter

def filter() -> ::Google::Protobuf::Struct
Returns
  • (::Google::Protobuf::Struct) — 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.

#filter=

def filter=(value) -> ::Google::Protobuf::Struct
Parameter
  • value (::Google::Protobuf::Struct) — 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.

Returns
  • (::Google::Protobuf::Struct) — 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.

#output_fields

def output_fields() -> ::Google::Cloud::VectorSearch::V1::OutputFields
Returns

#output_fields=

def output_fields=(value) -> ::Google::Cloud::VectorSearch::V1::OutputFields
Parameter
Returns

#search_field

def search_field() -> ::String
Returns
  • (::String) — Required. The vector field to search.

#search_field=

def search_field=(value) -> ::String
Parameter
  • value (::String) — Required. The vector field to search.
Returns
  • (::String) — Required. The vector field to search.

#search_hint

def search_hint() -> ::Google::Cloud::VectorSearch::V1::SearchHint
Returns

#search_hint=

def search_hint=(value) -> ::Google::Cloud::VectorSearch::V1::SearchHint
Parameter
Returns

#sparse_vector

def sparse_vector() -> ::Google::Cloud::VectorSearch::V1::SparseVector
Returns
  • (::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
Parameter
  • 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.

Returns
  • (::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
Returns
  • (::Integer) — Optional. The number of nearest neighbors to return.

#top_k=

def top_k=(value) -> ::Integer
Parameter
  • value (::Integer) — Optional. The number of nearest neighbors to return.
Returns
  • (::Integer) — Optional. The number of nearest neighbors to return.

#vector

def vector() -> ::Google::Cloud::VectorSearch::V1::DenseVector
Returns
  • (::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
Parameter
  • 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.

Returns
  • (::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.