pub struct FieldValueFactor { /* private fields */ }
Expand description
The field_value_factor
function allows you to use a field from a document to influence the
score.
It’s similar to using the script_score
function, however, it avoids the overhead of scripting.
If used on a multi-valued field, only the first value of the field is used in calculations.
As an example, imagine you have a document indexed with a numeric my-int
field and wish to
influence the score of a document with this field, an example doing so would look like:
FieldValueFactor::new("my-int")
.factor(1.2)
.modifier(FieldValueFactorModifier::Sqrt)
.missing(1.0)
Which will translate into the following formula for scoring:
sqrt(1.2 * doc['my-int'].value)
Implementations§
Source§impl FieldValueFactor
impl FieldValueFactor
Sourcepub fn new<T>(field: T) -> Selfwhere
T: ToString,
pub fn new<T>(field: T) -> Selfwhere
T: ToString,
Creates an instance of FieldValueFactor
field
- Field to be extracted from the document.
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.
Sourcepub fn modifier(self, modifier: FieldValueFactorModifier) -> Self
pub fn modifier(self, modifier: FieldValueFactorModifier) -> Self
Modifier to apply to the field value
Trait Implementations§
Source§impl Clone for FieldValueFactor
impl Clone for FieldValueFactor
Source§fn clone(&self) -> FieldValueFactor
fn clone(&self) -> FieldValueFactor
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more