pub struct Decay<T: Origin> { /* private fields */ }Expand description
Decay functions score a document with a function that decays depending on the distance of a numeric field value of the document from a user given origin. This is similar to a range query, but with smooth edges instead of boxes.
To use distance scoring on a query that has numerical fields, the user has to define an
origin and a scale for each field. The origin is needed to define the “central point”
from which the distance is calculated, and the scale to define the rate of decay.
Implementations
sourceimpl<O> Decay<O>where
O: Origin,
impl<O> Decay<O>where
O: Origin,
sourcepub fn new<T>(
function: DecayFunction,
field: T,
origin: O,
scale: <O as Origin>::Scale
) -> Selfwhere
T: ToString,
pub fn new<T>(
function: DecayFunction,
field: T,
origin: O,
scale: <O as Origin>::Scale
) -> Selfwhere
T: ToString,
Creates an instance of Decay
function- Decay function variantfield- Field to apply function toorigin- The point of origin used for calculating distance. Must be given as a number for numeric field, date for date fields and geo point for geo fields. Required for geo and numeric field. For date fields the default isnow. Date math (for example now-1h) is supported for origin.scale- Required for all types. Defines the distance from origin + offset at which the computed score will equaldecayparameter. For geo fields: Can be defined as number+unit (1km, 12m,…). Default unit is meters. For date fields: Can to be defined as a number+unit (“1h”, “10d”,…). Default unit is milliseconds. For numeric field: Any number.
Trait Implementations
sourceimpl From<Decay<GeoLocation>> for Function
impl From<Decay<GeoLocation>> for Function
sourcefn from(q: Decay<GeoLocation>) -> Self
fn from(q: Decay<GeoLocation>) -> Self
Converts to this type from the input type.
sourceimpl From<Decay<GeoLocation>> for Option<Function>
impl From<Decay<GeoLocation>> for Option<Function>
sourcefn from(q: Decay<GeoLocation>) -> Self
fn from(q: Decay<GeoLocation>) -> Self
Converts to this type from the input type.
sourceimpl<T: PartialEq + Origin> PartialEq<Decay<T>> for Decay<T>
impl<T: PartialEq + Origin> PartialEq<Decay<T>> for Decay<T>
impl<T: Origin> StructuralPartialEq for Decay<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for Decay<T>where
T: RefUnwindSafe,
<T as Origin>::Offset: RefUnwindSafe,
<T as Origin>::Scale: RefUnwindSafe,
impl<T> Send for Decay<T>where
T: Send,
<T as Origin>::Offset: Send,
<T as Origin>::Scale: Send,
impl<T> Sync for Decay<T>where
T: Sync,
<T as Origin>::Offset: Sync,
<T as Origin>::Scale: Sync,
impl<T> Unpin for Decay<T>where
T: Unpin,
<T as Origin>::Offset: Unpin,
<T as Origin>::Scale: Unpin,
impl<T> UnwindSafe for Decay<T>where
T: UnwindSafe,
<T as Origin>::Offset: UnwindSafe,
<T as Origin>::Scale: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more