#[non_exhaustive]pub struct VectorSearch {
pub search_field: String,
pub filter: Option<Struct>,
pub top_k: Option<i32>,
pub output_fields: Option<OutputFields>,
pub search_hint: Option<SearchHint>,
pub distance_metric: DistanceMetric,
pub vector_type: Option<VectorType>,
/* private fields */
}Expand description
Defines a search operation using a query vector.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.search_field: StringRequired. The vector field to search.
filter: Option<Struct>Optional. A JSON filter expression, e.g. {“genre”: {“$eq”: “sci-fi”}}, represented as a google.protobuf.Struct.
top_k: Option<i32>Optional. The number of nearest neighbors to return.
output_fields: Option<OutputFields>Optional. Mask specifying which fields to return.
search_hint: Option<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.
distance_metric: DistanceMetricOptional. The distance metric to use for the KNN search. If not specified, DOT_PRODUCT will be used as the default.
vector_type: Option<VectorType>Implementations§
Source§impl VectorSearch
impl VectorSearch
pub fn new() -> Self
Sourcepub fn set_search_field<T: Into<String>>(self, v: T) -> Self
pub fn set_search_field<T: Into<String>>(self, v: T) -> Self
Sourcepub fn set_filter<T>(self, v: T) -> Self
pub fn set_filter<T>(self, v: T) -> Self
Sourcepub fn set_or_clear_filter<T>(self, v: Option<T>) -> Self
pub fn set_or_clear_filter<T>(self, v: Option<T>) -> Self
Sourcepub fn set_or_clear_top_k<T>(self, v: Option<T>) -> Self
pub fn set_or_clear_top_k<T>(self, v: Option<T>) -> Self
Sourcepub fn set_output_fields<T>(self, v: T) -> Selfwhere
T: Into<OutputFields>,
pub fn set_output_fields<T>(self, v: T) -> Selfwhere
T: Into<OutputFields>,
Sets the value of output_fields.
§Example
use google_cloud_vectorsearch_v1::model::OutputFields;
let x = VectorSearch::new().set_output_fields(OutputFields::default()/* use setters */);Sourcepub fn set_or_clear_output_fields<T>(self, v: Option<T>) -> Selfwhere
T: Into<OutputFields>,
pub fn set_or_clear_output_fields<T>(self, v: Option<T>) -> Selfwhere
T: Into<OutputFields>,
Sets or clears the value of output_fields.
§Example
use google_cloud_vectorsearch_v1::model::OutputFields;
let x = VectorSearch::new().set_or_clear_output_fields(Some(OutputFields::default()/* use setters */));
let x = VectorSearch::new().set_or_clear_output_fields(None::<OutputFields>);Sourcepub fn set_search_hint<T>(self, v: T) -> Selfwhere
T: Into<SearchHint>,
pub fn set_search_hint<T>(self, v: T) -> Selfwhere
T: Into<SearchHint>,
Sets the value of search_hint.
§Example
use google_cloud_vectorsearch_v1::model::SearchHint;
let x = VectorSearch::new().set_search_hint(SearchHint::default()/* use setters */);Sourcepub fn set_or_clear_search_hint<T>(self, v: Option<T>) -> Selfwhere
T: Into<SearchHint>,
pub fn set_or_clear_search_hint<T>(self, v: Option<T>) -> Selfwhere
T: Into<SearchHint>,
Sets or clears the value of search_hint.
§Example
use google_cloud_vectorsearch_v1::model::SearchHint;
let x = VectorSearch::new().set_or_clear_search_hint(Some(SearchHint::default()/* use setters */));
let x = VectorSearch::new().set_or_clear_search_hint(None::<SearchHint>);Sourcepub fn set_distance_metric<T: Into<DistanceMetric>>(self, v: T) -> Self
pub fn set_distance_metric<T: Into<DistanceMetric>>(self, v: T) -> Self
Sets the value of distance_metric.
§Example
use google_cloud_vectorsearch_v1::model::DistanceMetric;
let x0 = VectorSearch::new().set_distance_metric(DistanceMetric::DotProduct);
let x1 = VectorSearch::new().set_distance_metric(DistanceMetric::CosineDistance);Sourcepub fn set_vector_type<T: Into<Option<VectorType>>>(self, v: T) -> Self
pub fn set_vector_type<T: Into<Option<VectorType>>>(self, v: T) -> Self
Sets the value of vector_type.
Note that all the setters affecting vector_type are mutually
exclusive.
§Example
use google_cloud_vectorsearch_v1::model::DenseVector;
let x = VectorSearch::new().set_vector_type(Some(
google_cloud_vectorsearch_v1::model::vector_search::VectorType::Vector(DenseVector::default().into())));Sourcepub fn vector(&self) -> Option<&Box<DenseVector>>
pub fn vector(&self) -> Option<&Box<DenseVector>>
The value of vector_type
if it holds a Vector, None if the field is not set or
holds a different branch.
Sourcepub fn set_vector<T: Into<Box<DenseVector>>>(self, v: T) -> Self
pub fn set_vector<T: Into<Box<DenseVector>>>(self, v: T) -> Self
Sets the value of vector_type
to hold a Vector.
Note that all the setters affecting vector_type are
mutually exclusive.
§Example
use google_cloud_vectorsearch_v1::model::DenseVector;
let x = VectorSearch::new().set_vector(DenseVector::default()/* use setters */);
assert!(x.vector().is_some());
assert!(x.sparse_vector().is_none());Sourcepub fn sparse_vector(&self) -> Option<&Box<SparseVector>>
pub fn sparse_vector(&self) -> Option<&Box<SparseVector>>
The value of vector_type
if it holds a SparseVector, None if the field is not set or
holds a different branch.
Sourcepub fn set_sparse_vector<T: Into<Box<SparseVector>>>(self, v: T) -> Self
pub fn set_sparse_vector<T: Into<Box<SparseVector>>>(self, v: T) -> Self
Sets the value of vector_type
to hold a SparseVector.
Note that all the setters affecting vector_type are
mutually exclusive.
§Example
use google_cloud_vectorsearch_v1::model::SparseVector;
let x = VectorSearch::new().set_sparse_vector(SparseVector::default()/* use setters */);
assert!(x.sparse_vector().is_some());
assert!(x.vector().is_none());Trait Implementations§
Source§impl Clone for VectorSearch
impl Clone for VectorSearch
Source§fn clone(&self) -> VectorSearch
fn clone(&self) -> VectorSearch
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more