Struct elasticsearch_dsl::search::queries::params::Decay [−][src]
pub struct Decay<T: Origin> { /* fields omitted */ }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
pub fn new(
function: DecayFunction,
field: impl Into<String>,
origin: T,
scale: <T as Origin>::Scale
) -> Self
pub fn new(
function: DecayFunction,
field: impl Into<String>,
origin: T,
scale: <T as Origin>::Scale
) -> Self
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.
If an offset is defined, the decay function will only compute the decay function for
documents with a distance greater than the defined offset.
The default is 0.
Trait Implementations
Auto Trait Implementations
impl<T> RefUnwindSafe for Decay<T> where
T: RefUnwindSafe,
<T as Origin>::Offset: RefUnwindSafe,
<T as Origin>::Scale: RefUnwindSafe,
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
Mutably borrows from an owned value. Read more