pub struct Query(/* private fields */);Expand description
One query clause.
Holds the JSON it will send, which is what makes Query::raw free and
keeps this from becoming a second, worse copy of the DSL’s type system.
Implementations§
Source§impl Query
impl Query
Sourcepub fn match_none() -> Query
pub fn match_none() -> Query
No document. Useful for an aggregation-only request, where the hits are paid for and thrown away.
Sourcepub fn matching(field: impl Into<String>, text: impl Into<String>) -> Match
pub fn matching(field: impl Into<String>, text: impl Into<String>) -> Match
Full-text search on one analysed field.
Returns a builder rather than a Query so the options that apply
only to match — above all Match::and — are reachable. It converts
wherever a Query is wanted.
Sourcepub fn match_phrase(field: impl Into<String>, text: impl Into<String>) -> Match
pub fn match_phrase(field: impl Into<String>, text: impl Into<String>) -> Match
The words in order and adjacent, rather than merely all present.
Sourcepub fn multi_match<S: Into<String>>(
text: impl Into<String>,
fields: impl IntoIterator<Item = S>,
) -> Query
pub fn multi_match<S: Into<String>>( text: impl Into<String>, fields: impl IntoIterator<Item = S>, ) -> Query
Full-text search across several fields at once.
A field may carry a weight — "title^3" — which is the ordinary way to
say a match in the title counts for more than one in the body.
Sourcepub fn term(field: impl Into<String>, value: impl Into<Json>) -> Query
pub fn term(field: impl Into<String>, value: impl Into<Json>) -> Query
An exact value, not analysed.
term compares against what is stored, so a text field almost never
matches one: "Hello World" is indexed as hello and world, and a
term query for Hello World finds nothing while reporting no error at
all. Use this on keyword, numeric, boolean and date fields, and
Query::matching on text.
Sourcepub fn terms<V: Into<Json>>(
field: impl Into<String>,
values: impl IntoIterator<Item = V>,
) -> Query
pub fn terms<V: Into<Json>>( field: impl Into<String>, values: impl IntoIterator<Item = V>, ) -> Query
Any one of several exact values — an IN list.
Sourcepub fn exists(field: impl Into<String>) -> Query
pub fn exists(field: impl Into<String>) -> Query
Documents where the field has any value at all.
The negation is BoolQuery::must_not around this, which is also the
only way to ask for “field is null”: Elasticsearch does not index a
null, so there is nothing to match on directly.
Sourcepub fn prefix(field: impl Into<String>, value: impl Into<String>) -> Query
pub fn prefix(field: impl Into<String>, value: impl Into<String>) -> Query
A value starting with this prefix, against the stored term.
Sourcepub fn wildcard(field: impl Into<String>, pattern: impl Into<String>) -> Query
pub fn wildcard(field: impl Into<String>, pattern: impl Into<String>) -> Query
A stored term matching a pattern, where * is any run and ? is one
character. Expensive on a large index, and a leading * especially so.
Sourcepub fn range(field: impl Into<String>) -> Range
pub fn range(field: impl Into<String>) -> Range
A bounded field: Query::range("age").gte(18).lt(65).
Sourcepub fn all_of<Q: Into<Query>>(clauses: impl IntoIterator<Item = Q>) -> BoolQuery
pub fn all_of<Q: Into<Query>>(clauses: impl IntoIterator<Item = Q>) -> BoolQuery
Every clause must match, and each contributes to the score.
Sourcepub fn any_of<Q: Into<Query>>(clauses: impl IntoIterator<Item = Q>) -> BoolQuery
pub fn any_of<Q: Into<Query>>(clauses: impl IntoIterator<Item = Q>) -> BoolQuery
At least one clause must match.
Sets minimum_should_match to 1, which is the difference between “any
of these” and “prefer these”: a bare should beside a must is only a
scoring hint, and a should list that nobody constrained happily
matches documents satisfying none of it.