pub struct Rescore { /* private fields */ }
Expand description
Rescoring can help to improve precision by reordering just the top (eg 100 - 500) documents returned by the query and post_filter phases, using a secondary (usually more costly) algorithm, instead of applying the costly algorithm to all documents in the index.
A rescore
request is executed on each shard before it returns its results to be sorted by the node handling the overall search request.
Currently the rescore API has only one implementation: the query rescorer, which uses a query to tweak the scoring. In the future, alternative rescorers may be made available, for example, a pair-wise rescorer.
To create a rescore
query with simple term
query:
Rescore::new(Query::term("title", "test"));
To create a rescore
query with simple term
query and optional fields:
Rescore::new(Query::term("title", "test"))
.rescore_query_weight(0.2)
.window_size(100);
https://www.elastic.co/guide/en/elasticsearch/reference/current/filter-search-results.html#rescore
Implementations§
Source§impl Rescore
impl Rescore
Sourcepub fn new<T>(query: T) -> Self
pub fn new<T>(query: T) -> Self
Creates a new instance of Rescore
query
- Second query which will be execute on top-k results returned by original query.
Sourcepub fn window_size(self, window_size: u64) -> Self
pub fn window_size(self, window_size: u64) -> Self
The number of docs which will be examined on each shard can be controlled by the window_size
parameter, which defaults to 10.
Sourcepub fn rescore_query_weight<T>(self, rescore_query_weight: T) -> Selfwhere
T: AsPrimitive<f32>,
pub fn rescore_query_weight<T>(self, rescore_query_weight: T) -> Selfwhere
T: AsPrimitive<f32>,
The relative importance of the rescore query can be controlled with the rescore_query_weight
respectively. Both default to 1.
Sourcepub fn query_weight<T>(self, query_weight: T) -> Selfwhere
T: AsPrimitive<f32>,
pub fn query_weight<T>(self, query_weight: T) -> Selfwhere
T: AsPrimitive<f32>,
The relative importance of the original query can be controlled with the query_weight
respectively. Both default to 1.
Sourcepub fn score_mode(self, score_mode: ScoreMode) -> Self
pub fn score_mode(self, score_mode: ScoreMode) -> Self
The way the scores are combined can be controlled with the