Struct elasticsearch_dsl::search::queries::specialized::RankFeatureQuery
source · [−]pub struct RankFeatureQuery { /* private fields */ }
Expand description
Boosts the relevance score of documents based on the numeric value of a rank_feature
or
rank_features
field.
To create a rank feature query:
Query::rank_feature("test");
To apply mathematical functions:
Query::rank_feature("test").saturation();
Query::rank_feature("test").saturation().pivot(2.2);
Query::rank_feature("test").logarithm(3.0);
Query::rank_feature("test").sigmoid(1.0, 2.0);
Query::rank_feature("test").linear();
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-rank-feature-query.html
Implementations
sourceimpl RankFeatureQuery
impl RankFeatureQuery
sourcepub fn saturation(self) -> RankFeatureSaturationQuery
pub fn saturation(self) -> RankFeatureSaturationQuery
The saturation
function gives a score equal to S / (S + pivot)
, where S
is the value
of the rank feature field and pivot
is a configurable pivot value so that the result will
be less than 0.5
if S
is less than pivot and greater than 0.5
otherwise.
Scores are always (0,1)
.
If the rank feature has a negative score impact then the function will be computed as
pivot / (S + pivot)
, which decreases when S
increases.
If a pivot
value is not provided, Elasticsearch computes a default value equal to the
approximate geometric mean of all rank feature values in the index. We recommend using this
default value if you haven’t had the opportunity to train a good pivot value.
sourcepub fn logarithm(self, scaling_factor: f64) -> RankFeatureLogarithmQuery
pub fn logarithm(self, scaling_factor: f64) -> RankFeatureLogarithmQuery
The log
function gives a score equal to log(scaling_factor + S)
, where S
is the value
of the rank feature field and scaling_factor
is a configurable scaling factor.
Scores are unbounded.
This function only supports rank features that have a positive score impact.
sourcepub fn sigmoid(self, pivot: f64, exponent: f64) -> RankFeatureSigmoidQuery
pub fn sigmoid(self, pivot: f64, exponent: f64) -> RankFeatureSigmoidQuery
The sigmoid
function is an extension of saturation
which adds a configurable exponent.
Scores are computed as S^exp^ / (S^exp^ + pivot^exp^)
. Like for the saturation
function,
pivot
is the value of S
that gives a score of 0.5
and scores are (0,1)
.
The exponent
must be positive and is typically in [0.5, 1]
. A good value should be
computed via training. If you don’t have the opportunity to do so, we recommend you use the
saturation
function instead.
sourcepub fn linear(self) -> RankFeatureLinearQuery
pub fn linear(self) -> RankFeatureLinearQuery
The linear
function is the simplest function, and gives a score equal to the indexed
value of S
, where S
is the value of the rank feature field. If a rank feature field is
indexed with "positive_score_impact": true
, its indexed value is equal to S
and rounded
to preserve only 9 significant bits for the precision. If a rank feature field is indexed
with "positive_score_impact": false
, its indexed value is equal to 1/S
and rounded to
preserve only 9 significant bits for the precision.
sourcepub fn boost<B>(self, boost: B) -> Self where
B: TryInto<Boost>,
pub fn boost<B>(self, boost: B) -> Self where
B: TryInto<Boost>,
Floating point number used to decrease or increase the
relevance scores
of a query. Defaults to 1.0
.
You can use the boost parameter to adjust relevance scores for searches containing two or more queries.
Boost values are relative to the default value of 1.0
.
A boost value between 0 and 1.0
decreases the relevance score.
A value greater than 1.0
increases the relevance score.
Trait Implementations
sourceimpl Clone for RankFeatureQuery
impl Clone for RankFeatureQuery
sourcefn clone(&self) -> RankFeatureQuery
fn clone(&self) -> RankFeatureQuery
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for RankFeatureQuery
impl Debug for RankFeatureQuery
sourceimpl From<RankFeatureQuery> for Query
impl From<RankFeatureQuery> for Query
sourcefn from(q: RankFeatureQuery) -> Self
fn from(q: RankFeatureQuery) -> Self
Converts to this type from the input type.
sourceimpl From<RankFeatureQuery> for Option<Query>
impl From<RankFeatureQuery> for Option<Query>
sourcefn from(q: RankFeatureQuery) -> Self
fn from(q: RankFeatureQuery) -> Self
Converts to this type from the input type.
sourceimpl From<RankFeatureQuery> for Queries
impl From<RankFeatureQuery> for Queries
sourcefn from(q: RankFeatureQuery) -> Self
fn from(q: RankFeatureQuery) -> Self
Converts to this type from the input type.
sourceimpl PartialEq<Query> for RankFeatureQuery
impl PartialEq<Query> for RankFeatureQuery
sourceimpl PartialEq<RankFeatureQuery> for RankFeatureQuery
impl PartialEq<RankFeatureQuery> for RankFeatureQuery
sourcefn eq(&self, other: &RankFeatureQuery) -> bool
fn eq(&self, other: &RankFeatureQuery) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &RankFeatureQuery) -> bool
fn ne(&self, other: &RankFeatureQuery) -> bool
This method tests for !=
.
sourceimpl PartialEq<RankFeatureQuery> for Query
impl PartialEq<RankFeatureQuery> for Query
sourceimpl Serialize for RankFeatureQuery
impl Serialize for RankFeatureQuery
impl StructuralPartialEq for RankFeatureQuery
Auto Trait Implementations
impl RefUnwindSafe for RankFeatureQuery
impl Send for RankFeatureQuery
impl Sync for RankFeatureQuery
impl Unpin for RankFeatureQuery
impl UnwindSafe for RankFeatureQuery
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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