Enum Rewrite

Source
pub enum Rewrite {
    ConstantScore,
    ConstantScoreBoolean,
    ScoringBoolean,
    TopTermsBlendedFrequencies(u64),
    TopTermsBoost(u64),
    TopTerms(u64),
}
Expand description

Method used to rewrite the query.

This parameter is for expert users only. Changing the value of this parameter can impact search performance and relevance.

The rewrite parameter determines:

  • How Lucene calculates the relevance scores for each matching document
  • Whether Lucene changes the original query to a bool query or bit set
  • If changed to a bool query, which term query clauses are included

Performance considerations for the rewrite parameter

For most uses, we recommend using the constant_score, constant_score_boolean, or top_terms_boost_N rewrite methods.

Other methods calculate relevance scores. These score calculations are often expensive and do not improve query results.

Variants§

§

ConstantScore

Uses the constant_score_boolean method for fewer matching terms. Otherwise, this method finds all matching terms in sequence and returns matching documents using a bit set.

§

ConstantScoreBoolean

Assigns each document a relevance score equal to the boost parameter.

This method changes the original query to a bool query. This bool query contains a should clause and term query for each matching term.

This method can cause the final bool query to exceed the clause limit in the indices.query.bool.max_clause_count setting. If the query exceeds this limit, Elasticsearch returns an error.

§

ScoringBoolean

Calculates a relevance score for each matching document.

This method changes the original query to a bool query. This bool query contains a should clause and term query for each matching term.

This method can cause the final bool query to exceed the clause limit in the indices.query.bool.max_clause_count setting. If the query exceeds this limit, Elasticsearch returns an error.

§

TopTermsBlendedFrequencies(u64)

Calculates a relevance score for each matching document as if all terms had the same frequency. This frequency is the maximum frequency of all matching terms.

This method changes the original query to a bool query. This bool query contains a should clause and term query for each matching term.

The final bool query only includes term queries for the top N scoring terms.

You can use this method to avoid exceeding the clause limit in the indices.query.bool.max_clause_count setting.

§

TopTermsBoost(u64)

Assigns each matching document a relevance score equal to the boost parameter.

This method changes the original query to a bool query. This bool query contains a should clause and term query for each matching term.

The final bool query only includes term queries for the top N terms.

You can use this method to avoid exceeding the clause limit in the indices.query.bool.max_clause_count setting.

§

TopTerms(u64)

Calculates a relevance score for each matching document.

This method changes the original query to a bool query. This bool query contains a should clause and term query for each matching term.

The final bool query only includes term queries for the top N scoring terms.

You can use this method to avoid exceeding the clause limit in the indices.query.bool.max_clause_count setting.

Trait Implementations§

Source§

impl Clone for Rewrite

Source§

fn clone(&self) -> Rewrite

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Rewrite

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Rewrite

Source§

fn eq(&self, other: &Rewrite) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Rewrite

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Copy for Rewrite

Source§

impl Eq for Rewrite

Source§

impl StructuralPartialEq for Rewrite

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.