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(query: impl Into<Option<Query>>) -> Self
pub fn new(query: impl Into<Option<Query>>) -> 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: impl TryInto<u64>) -> Self
pub fn window_size(self, window_size: impl TryInto<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(self, rescore_query_weight: impl Into<f64>) -> Self
pub fn rescore_query_weight(self, rescore_query_weight: impl Into<f64>) -> Self
The relative importance of the rescore query can be controlled with the rescore_query_weight respectively. Both default to 1.
sourcepub fn query_weight(self, query_weight: impl Into<f64>) -> Self
pub fn query_weight(self, query_weight: impl Into<f64>) -> Self
The relative importance of the original query can be controlled with the query_weight respectively. Both default to 1.
Trait Implementations
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
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more