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(FunctionBoostMode::Max)
    .boost(1.1)
    .name("test");

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html

Implementations§

Push function to the list

Maximum score value after applying all the functions

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.

Each document is scored by the defined functions. The parameter score_mode specifies how the computed scores are combined

The newly computed score is combined with the score of the query. The parameter boost_mode defines how.

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.

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/elasticsearch/reference/current/query-dsl-bool-query.html#named-queries

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Converts to this type from the input type.
Converts to this type from the input type.
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.