Skip to main content

Near

Struct Near 

Source
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>

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl<T> Debug for Near<'_, T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, T> !RefUnwindSafe for Near<'a, T>

§

impl<'a, T> !Send for Near<'a, T>

§

impl<'a, T> !Sync for Near<'a, T>

§

impl<'a, T> !UnwindSafe for Near<'a, T>

§

impl<'a, T> Freeze for Near<'a, T>
where &'a Docs<T>: Freeze, Vector<T>: Freeze,

§

impl<'a, T> Unpin for Near<'a, T>
where &'a Docs<T>: Unpin, Vector<T>: Unpin,

§

impl<'a, T> UnsafeUnpin for Near<'a, T>
where &'a Docs<T>: UnsafeUnpin, Vector<T>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.