Struct elasticsearch_dsl::search::queries::compound::FunctionScoreQuery
source · [−]pub struct FunctionScoreQuery { /* private fields */ }
Expand description
The function_score
allows you to modify the score of documents that are retrieved by a query.
This can be useful if, for example, a score function is computationally expensive and it is sufficient to compute the score on a filtered set of documents.
To use function_score
, the user has to define a query and one or more functions, that compute
a new score for each document returned by the query.
To create function_score query:
Query::function_score(Query::term("test", 1))
.function(RandomScore::new())
.function(Weight::new(2.0))
.max_boost(2.2)
.min_score(2.3)
.score_mode(FunctionScoreMode::Avg)
.boost_mode(FunctionScoreBoostMode::Max)
.boost(1.1)
.name("test");
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html
Implementations
sourceimpl FunctionScoreQuery
impl FunctionScoreQuery
sourcepub fn max_boost(self, max_boost: impl TryInto<Boost>) -> Self
pub fn max_boost(self, max_boost: impl TryInto<Boost>) -> Self
Maximum score value after applying all the functions
sourcepub fn min_score(self, min_score: impl Into<f32>) -> Self
pub fn min_score(self, min_score: impl Into<f32>) -> Self
By default, modifying the score does not change which documents match. To exclude documents
that do not meet a certain score threshold the min_score
parameter can be set to the
desired score threshold.
sourcepub fn score_mode(self, score_mode: FunctionScoreMode) -> Self
pub fn score_mode(self, score_mode: FunctionScoreMode) -> Self
Each document is scored by the defined functions. The parameter score_mode
specifies how
the computed scores are combined
sourcepub fn boost_mode(self, boost_mode: FunctionScoreBoostMode) -> Self
pub fn boost_mode(self, boost_mode: FunctionScoreBoostMode) -> Self
The newly computed score is combined with the score of the query. The parameter
boost_mode
defines how.
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 FunctionScoreQuery
impl Clone for FunctionScoreQuery
sourcefn clone(&self) -> FunctionScoreQuery
fn clone(&self) -> FunctionScoreQuery
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 FunctionScoreQuery
impl Debug for FunctionScoreQuery
sourceimpl From<FunctionScoreQuery> for Query
impl From<FunctionScoreQuery> for Query
sourcefn from(q: FunctionScoreQuery) -> Self
fn from(q: FunctionScoreQuery) -> Self
Converts to this type from the input type.
sourceimpl From<FunctionScoreQuery> for Option<Query>
impl From<FunctionScoreQuery> for Option<Query>
sourcefn from(q: FunctionScoreQuery) -> Self
fn from(q: FunctionScoreQuery) -> Self
Converts to this type from the input type.
sourceimpl From<FunctionScoreQuery> for Queries
impl From<FunctionScoreQuery> for Queries
sourcefn from(q: FunctionScoreQuery) -> Self
fn from(q: FunctionScoreQuery) -> Self
Converts to this type from the input type.
sourceimpl PartialEq<FunctionScoreQuery> for FunctionScoreQuery
impl PartialEq<FunctionScoreQuery> for FunctionScoreQuery
sourcefn eq(&self, other: &FunctionScoreQuery) -> bool
fn eq(&self, other: &FunctionScoreQuery) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &FunctionScoreQuery) -> bool
fn ne(&self, other: &FunctionScoreQuery) -> bool
This method tests for !=
.
sourceimpl PartialEq<FunctionScoreQuery> for Query
impl PartialEq<FunctionScoreQuery> for Query
sourceimpl PartialEq<Query> for FunctionScoreQuery
impl PartialEq<Query> for FunctionScoreQuery
sourceimpl Serialize for FunctionScoreQuery
impl Serialize for FunctionScoreQuery
impl StructuralPartialEq for FunctionScoreQuery
Auto Trait Implementations
impl RefUnwindSafe for FunctionScoreQuery
impl Send for FunctionScoreQuery
impl Sync for FunctionScoreQuery
impl Unpin for FunctionScoreQuery
impl UnwindSafe for FunctionScoreQuery
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