pub struct SearchParams {
pub k: usize,
pub ef: Option<usize>,
pub metric: DistanceMetric,
pub filter: Option<Filter>,
}Expand description
The parameters of a nearest-neighbor search.
k is how many results to return, metric is how distance is measured,
ef is an optional search-breadth knob (the candidate-list size some
approximate indexes expose; ignored by exact search), and filter is an
optional metadata predicate restricting which records are eligible. Start
from SearchParams::new and set the optional fields as needed.
§Examples
use iqdb_types::{DistanceMetric, Filter, SearchParams, Value};
let params = SearchParams {
filter: Some(Filter::eq("published", Value::Bool(true))),
..SearchParams::new(10, DistanceMetric::Cosine)
};
assert_eq!(params.k, 10);
assert_eq!(params.metric, DistanceMetric::Cosine);
assert_eq!(params.ef, None);
assert!(params.filter.is_some());Fields§
§k: usizeThe number of nearest neighbors to return.
ef: Option<usize>Optional search breadth (candidate-list size) for approximate indexes;
None lets the engine choose, and exact search ignores it.
metric: DistanceMetricThe distance metric used to rank candidates.
filter: Option<Filter>Optional metadata predicate restricting which records are eligible.
Implementations§
Source§impl SearchParams
impl SearchParams
Sourcepub fn new(k: usize, metric: DistanceMetric) -> SearchParams
pub fn new(k: usize, metric: DistanceMetric) -> SearchParams
Creates parameters for a top-k search under metric, with no search
breadth and no filter.
§Examples
use iqdb_types::{DistanceMetric, SearchParams};
let params = SearchParams::new(5, DistanceMetric::Euclidean);
assert_eq!(params.k, 5);
assert_eq!(params.ef, None);
assert!(params.filter.is_none());Trait Implementations§
Source§impl Clone for SearchParams
impl Clone for SearchParams
Source§fn clone(&self) -> SearchParams
fn clone(&self) -> SearchParams
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SearchParams
impl Debug for SearchParams
Source§impl<'de> Deserialize<'de> for SearchParams
impl<'de> Deserialize<'de> for SearchParams
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<SearchParams, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<SearchParams, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for SearchParams
impl PartialEq for SearchParams
Source§fn eq(&self, other: &SearchParams) -> bool
fn eq(&self, other: &SearchParams) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for SearchParams
impl Serialize for SearchParams
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for SearchParams
Auto Trait Implementations§
impl Freeze for SearchParams
impl RefUnwindSafe for SearchParams
impl Send for SearchParams
impl Sync for SearchParams
impl Unpin for SearchParams
impl UnsafeUnpin for SearchParams
impl UnwindSafe for SearchParams
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more