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).
Terms
Match any of a set of exact values.
Match
Full-text match: analyze query text, build bool of term queries.
MatchPhrase
Phrase match: terms must appear in order at consecutive positions.
MatchBoolPrefix
Match bool prefix: analyzes text, all tokens become term queries except the last which becomes a prefix query. Rewrites to bool/should.
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
must: Vec<ScoringExpression>should: Vec<ScoringExpression>must_not: Vec<ScoringExpression>filter: Vec<ScoringExpression>DisMax
Disjunction max: return the score from the best-matching sub-query, plus tie_breaker * sum of other matching scores.
Exists
Field exists (has a non-null value).
Prefix
Prefix match on a field’s terms.
ConstantScore
Wrap a query in filter context with a constant score.
Nested
Nested query: search within nested document arrays.
GeoDistance
Geographic distance query.
GeoBoundingBox
Geographic bounding box query.
Fields
GeoShape
Geographic shape query with spatial relation.
See [[feature-geo-shape]] and [[de-9im]].
Range
Numeric range query on a field.
Boost
Boost wrapper: multiplies inner query’s score by a factor.
ScriptScore
Script score: compiled expression-based custom scoring.
FunctionScore
Function score: modify query scores with scoring functions.
Fields
query: Box<ScoringExpression>functions: Vec<ScoreFunction>score_mode: FunctionScoreModeboost_mode: FunctionBoostModeBoosting
Boosting: positive query with score demotion for negative matches.
Fuzzy
Fuzzy match: terms within edit distance.
Regexp
Regexp match on term dictionary.
Wildcard
Wildcard match: * (any chars) and ? (single char).
MultiMatch
Multi-field match: search the same query across multiple fields.
Defaults to best_fields (dis_max with tie_breaker=0.0).
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
MatchAll
Match all documents.
MatchNone
Match no documents.
Implementations§
Source§impl ScoringExpression
impl ScoringExpression
Sourcepub fn bool_query(
must: Vec<ScoringExpression>,
should: Vec<ScoringExpression>,
must_not: Vec<ScoringExpression>,
filter: Vec<ScoringExpression>,
) -> Self
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
impl Clone for ScoringExpression
Source§fn clone(&self) -> ScoringExpression
fn clone(&self) -> ScoringExpression
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ScoringExpression
impl Debug for ScoringExpression
Source§impl PartialEq for ScoringExpression
impl PartialEq for ScoringExpression
Source§fn eq(&self, other: &ScoringExpression) -> bool
fn eq(&self, other: &ScoringExpression) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for ScoringExpression
Auto Trait Implementations§
impl Freeze for ScoringExpression
impl RefUnwindSafe for ScoringExpression
impl Send for ScoringExpression
impl Sync for ScoringExpression
impl Unpin for ScoringExpression
impl UnsafeUnpin for ScoringExpression
impl UnwindSafe for ScoringExpression
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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