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§
source§impl<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.
sourcepub fn weight<T>(self, weight: T) -> Selfwhere
T: AsPrimitive<f32>,
pub fn weight<T>(self, weight: T) -> Selfwhere
T: AsPrimitive<f32>,
The weight score allows you to multiply the score by the provided weight. This can sometimes be desired
since boost value set on specific queries gets normalized, while for this score function it does not.
The number value is of type float.
Trait Implementations§
source§impl From<Decay<GeoLocation>> for Function
impl From<Decay<GeoLocation>> for Function
source§fn from(q: Decay<GeoLocation>) -> Self
fn from(q: Decay<GeoLocation>) -> Self
source§impl From<Decay<GeoLocation>> for Option<Function>
impl From<Decay<GeoLocation>> for Option<Function>
source§fn from(q: Decay<GeoLocation>) -> Self
fn from(q: Decay<GeoLocation>) -> Self
impl<T: Origin> StructuralPartialEq for Decay<T>
Auto Trait Implementations§
impl<T> Freeze for Decay<T>
impl<T> RefUnwindSafe for Decay<T>
impl<T> Send for Decay<T>
impl<T> Sync for Decay<T>
impl<T> Unpin for Decay<T>
impl<T> UnwindSafe for Decay<T>
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,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)