Skip to main content

ScoringExpression

Enum ScoringExpression 

Source
pub enum ScoringExpression {
Show 27 variants Term { field: String, value: String, }, Terms { field: String, values: Vec<String>, }, Match { field: String, query: String, analyzer: Option<String>, }, MatchPhrase { field: String, query: String, analyzer: Option<String>, }, MatchBoolPrefix { field: String, query: String, analyzer: Option<String>, }, Bool { must: Vec<ScoringExpression>, should: Vec<ScoringExpression>, must_not: Vec<ScoringExpression>, filter: Vec<ScoringExpression>, minimum_should_match: Option<u32>, }, DisMax { queries: Vec<ScoringExpression>, tie_breaker: f32, }, Exists { field: String, }, Prefix { field: String, value: String, }, ConstantScore { query: Box<ScoringExpression>, boost: f32, }, Nested { path: String, query: Box<ScoringExpression>, inner_hits: Option<InnerHitsConfig>, }, GeoDistance { field: String, lat: f64, lon: f64, distance: String, }, GeoBoundingBox { field: String, top_left_lat: f64, top_left_lon: f64, bottom_right_lat: f64, bottom_right_lon: f64, }, GeoShape { field: String, shape: GeoShapeValue, relation: SpatialRelation, }, Range { field: String, gte: Option<f64>, gt: Option<f64>, lte: Option<f64>, lt: Option<f64>, }, Boost { query: Box<ScoringExpression>, boost: f32, }, ScriptScore { query: Box<ScoringExpression>, script: String, params: HashMap<String, f64>, }, FunctionScore { query: Box<ScoringExpression>, functions: Vec<ScoreFunction>, score_mode: FunctionScoreMode, boost_mode: FunctionBoostMode, }, Boosting { positive: Box<ScoringExpression>, negative: Box<ScoringExpression>, negative_boost: f32, }, Fuzzy { field: String, value: String, fuzziness: u32, }, Regexp { field: String, value: String, }, Wildcard { field: String, value: String, }, MultiMatch { fields: Vec<String>, query: String, analyzer: Option<String>, tie_breaker: f32, }, Span(SpanExpression), Knn { field: String, query_vector: Vec<f32>, k: usize, num_candidates: usize, threshold: Option<f32>, }, MatchAll, MatchNone,
}
Expand description

Typed query expression. Each variant maps to an ES-compatible query type.

Variants§

§

Term

Exact term match on a field (no analysis).

Fields

§field: String
§value: String
§

Terms

Match any of a set of exact values.

Fields

§field: String
§values: Vec<String>
§

Match

Full-text match: analyze query text, build bool of term queries.

Fields

§field: String
§query: String
§analyzer: Option<String>
§

MatchPhrase

Phrase match: terms must appear in order at consecutive positions.

Fields

§field: String
§query: String
§analyzer: Option<String>
§

MatchBoolPrefix

Match bool prefix: analyzes text, all tokens become term queries except the last which becomes a prefix query. Rewrites to bool/should.

Fields

§field: String
§query: String
§analyzer: Option<String>
§

Bool

Boolean combination of sub-queries.

minimum_should_match requires at least N should clauses to match. Default behavior: if must/filter present and msm is None, should clauses are optional (boost only). If no must/filter and msm is None, at least 1 should must match.

See [[feature-minimum-should-match]].

Fields

§minimum_should_match: Option<u32>
§

DisMax

Disjunction max: return the score from the best-matching sub-query, plus tie_breaker * sum of other matching scores.

Fields

§tie_breaker: f32
§

Exists

Field exists (has a non-null value).

Fields

§field: String
§

Prefix

Prefix match on a field’s terms.

Fields

§field: String
§value: String
§

ConstantScore

Wrap a query in filter context with a constant score.

Fields

§boost: f32
§

Nested

Nested query: search within nested document arrays.

§

GeoDistance

Geographic distance query.

Fields

§field: String
§lat: f64
§lon: f64
§distance: String
§

GeoBoundingBox

Geographic bounding box query.

Fields

§field: String
§top_left_lat: f64
§top_left_lon: f64
§bottom_right_lat: f64
§bottom_right_lon: f64
§

GeoShape

Geographic shape query with spatial relation.

See [[feature-geo-shape]] and [[de-9im]].

Fields

§field: String
§

Range

Numeric range query on a field.

Fields

§field: String
§

Boost

Boost wrapper: multiplies inner query’s score by a factor.

Fields

§boost: f32
§

ScriptScore

Script score: compiled expression-based custom scoring.

Fields

§script: String
§params: HashMap<String, f64>
§

FunctionScore

Function score: modify query scores with scoring functions.

Fields

§functions: Vec<ScoreFunction>
§

Boosting

Boosting: positive query with score demotion for negative matches.

Fields

§negative_boost: f32
§

Fuzzy

Fuzzy match: terms within edit distance.

Fields

§field: String
§value: String
§fuzziness: u32
§

Regexp

Regexp match on term dictionary.

Fields

§field: String
§value: String
§

Wildcard

Wildcard match: * (any chars) and ? (single char).

Fields

§field: String
§value: String
§

MultiMatch

Multi-field match: search the same query across multiple fields. Defaults to best_fields (dis_max with tie_breaker=0.0).

Fields

§fields: Vec<String>
§query: String
§analyzer: Option<String>
§tie_breaker: f32
§

Span(SpanExpression)

Span-typed query (position-aware). The inner SpanExpression enumerates the concrete span variants; this single wrapper parallels QueryExpression::Scoring wrapping a ScoringExpression — one concept, one representation.

§

Knn

Approximate k-nearest-neighbor search on a dense_vector field.

Results are pre-materialized at bind time via HNSW graph traversal. The scorer iterates a small sorted array of (doc_id, score) pairs. Score conversion is metric-specific (see crate::vector::distance_to_score).

See [[feature-knn-query-type]].

Fields

§field: String
§query_vector: Vec<f32>
§num_candidates: usize
§threshold: Option<f32>

Minimum score threshold. Results with score < threshold are excluded.

§

MatchAll

Match all documents.

§

MatchNone

Match no documents.

Implementations§

Source§

impl ScoringExpression

Source

pub fn bool_query( must: Vec<ScoringExpression>, should: Vec<ScoringExpression>, must_not: Vec<ScoringExpression>, filter: Vec<ScoringExpression>, ) -> Self

Convenience constructor for a bool query.

Trait Implementations§

Source§

impl Clone for ScoringExpression

Source§

fn clone(&self) -> ScoringExpression

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ScoringExpression

Source§

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

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

impl PartialEq for ScoringExpression

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 StructuralPartialEq for ScoringExpression

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool