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
sourceimpl Rescore
impl Rescore
sourcepub fn new<T>(query: T) -> Self where
T: Into<Option<Query>>,
pub fn new<T>(query: T) -> Self where
T: Into<Option<Query>>,
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) -> Self where
T: AsPrimitive<f32>,
pub fn rescore_query_weight<T>(self, rescore_query_weight: T) -> Self where
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) -> Self where
T: AsPrimitive<f32>,
pub fn query_weight<T>(self, query_weight: T) -> Self where
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
Trait Implementations
sourceimpl IntoIterator for Rescore
impl IntoIterator for Rescore
impl StructuralPartialEq for Rescore
Auto Trait Implementations
impl RefUnwindSafe for Rescore
impl Send for Rescore
impl Sync for Rescore
impl Unpin for Rescore
impl UnwindSafe for Rescore
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