pub struct Near<'a, T> { /* private fields */ }Expand description
A nearest neighbour search being put together, from Docs::near.
A builder rather than a method with a list of filters, because the filters
are over different fields with different types and a slice of them would
have to give that up. Turning a value into an index key can fail, so a
filter that cannot be one is kept here and handed over at the end rather
than making every step return a Result.
Implementations§
Source§impl<'a, T: Document> Near<'a, T>
impl<'a, T: Document> Near<'a, T>
Sourcepub fn filter<V: Asked>(
self,
path: impl Into<Path<T, V>>,
value: &V::Ask,
) -> Near<'a, T>
pub fn filter<V: Asked>( self, path: impl Into<Path<T, V>>, value: &V::Ask, ) -> Near<'a, T>
Only documents whose value at path is value.
Two of these means both, so it is a conjunction and not a choice. The path has to carry an ordinary index, because what the scan tests is the keys that index filed the document under.
Sourcepub fn take(self, k: usize) -> Result<Vec<T>>
pub fn take(self, k: usize) -> Result<Vec<T>>
The k nearest that pass every filter, nearest first.
§Errors
Code::Invalid if a filter names a path with no index on it, if a
filter value cannot be an index key, or if the query vector is not as
wide as the path says. Code::Corrupt if a stored document is not a
T.
Sourcepub fn scored(self, k: usize) -> Result<Vec<(T, f32)>>
pub fn scored(self, k: usize) -> Result<Vec<(T, f32)>>
The same, each document with how far it is.
The distance is what the collection measures, so for the cosine default it is one minus the cosine and nearer is smaller. It is measured against the full precision vector rather than against the code.
§Errors
The same as Near::take.