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(Query::term("test", 1))
.function(
RandomScore::new()
.filter(Query::term("test", 1))
.weight(2.0),
)
.function(Weight::new(2.0))
.max_boost(2.2)
.min_score(2.3)
.score_mode(FunctionScoreMode::Avg)
.boost_mode(FunctionBoostMode::Max)
.boost(1.1)
.name("test");https://www.elastic.co/guide/en/opensearch/reference/current/query-dsl-function-score-query.html
Implementations§
Source§impl<'de> FunctionScoreQuery
impl<'de> FunctionScoreQuery
pub fn deserialize<__D>(
__deserializer: __D,
) -> Result<FunctionScoreQuery, __D::Error>where
__D: Deserializer<'de>,
Source§impl FunctionScoreQuery
impl FunctionScoreQuery
pub fn serialize<__S>(
__self: &FunctionScoreQuery,
__serializer: __S,
) -> Result<__S::Ok, __S::Error>where
__S: Serializer,
Source§impl FunctionScoreQuery
impl FunctionScoreQuery
Sourcepub fn boost<T>(self, boost: T) -> Selfwhere
T: AsPrimitive<f32>,
pub fn boost<T>(self, boost: T) -> Selfwhere
T: AsPrimitive<f32>,
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.
Sourcepub fn name<S>(self, name: S) -> Selfwhere
S: ToString,
pub fn name<S>(self, name: S) -> Selfwhere
S: ToString,
You can use named queries to track which queries matched
returned documents. If named queries are used, the response
includes a matched_queries property for each hit.
https://www.elastic.co/guide/en/opensearch/reference/current/query-dsl-bool-query.html#named-queries
Sourcepub fn max_boost<T>(self, max_boost: T) -> Selfwhere
T: AsPrimitive<f32>,
pub fn max_boost<T>(self, max_boost: T) -> Selfwhere
T: AsPrimitive<f32>,
Maximum score value after applying all the functions
Sourcepub fn min_score<T>(self, min_score: T) -> Self
pub fn min_score<T>(self, min_score: T) -> 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: FunctionBoostMode) -> Self
pub fn boost_mode(self, boost_mode: FunctionBoostMode) -> Self
The newly computed score is combined with the score of the query. The
parameter boost_mode defines how.
Trait Implementations§
Source§impl Clone for FunctionScoreQuery
impl Clone for FunctionScoreQuery
Source§fn clone(&self) -> FunctionScoreQuery
fn clone(&self) -> FunctionScoreQuery
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FunctionScoreQuery
impl Debug for FunctionScoreQuery
Source§impl<'de> Deserialize<'de> for FunctionScoreQuery
impl<'de> Deserialize<'de> for FunctionScoreQuery
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl From<FunctionScoreQuery> for Query
impl From<FunctionScoreQuery> for Query
Source§fn from(q: FunctionScoreQuery) -> Self
fn from(q: FunctionScoreQuery) -> Self
Source§impl From<FunctionScoreQuery> for Option<Query>
impl From<FunctionScoreQuery> for Option<Query>
Source§fn from(q: FunctionScoreQuery) -> Self
fn from(q: FunctionScoreQuery) -> Self
Source§impl IntoIterator for FunctionScoreQuery
impl IntoIterator for FunctionScoreQuery
Source§impl PartialEq for FunctionScoreQuery
impl PartialEq for FunctionScoreQuery
Source§fn eq(&self, other: &FunctionScoreQuery) -> bool
fn eq(&self, other: &FunctionScoreQuery) -> bool
self and other values to be equal, and is used by ==.Source§impl PartialEq<FunctionScoreQuery> for Query
impl PartialEq<FunctionScoreQuery> for Query
Source§fn eq(&self, other: &FunctionScoreQuery) -> bool
fn eq(&self, other: &FunctionScoreQuery) -> bool
self and other values to be equal, and is used by ==.