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.