Struct elasticsearch_dsl::search::queries::term_level::FuzzyQuery
source · [−]pub struct FuzzyQuery { /* private fields */ }
Expand description
Returns documents that contain terms similar to the search term, as measured by a Levenshtein edit distance.
An edit distance is the number of one-character changes needed to turn one term into another. These changes can include:
- Changing a character (box → fox)
- Removing a character (black → lack)
- Inserting a character (sic → sick)
- Transposing two adjacent characters (act → cat) To find similar terms, the fuzzy query creates a set of all possible variations, or expansions, of the search term within a specified edit distance. The query then returns exact matches for each expansion.
To create a fuzzy query with numeric values:
Query::fuzzy("test", 123);
To create a fuzzy query with string values and optional fields:
Query::fuzzy("test", "username")
.boost(2)
.name("test");
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-fuzzy-query.html
Implementations
sourceimpl FuzzyQuery
impl FuzzyQuery
sourcepub fn fuzziness(self, fuzziness: impl Into<Fuzziness>) -> Self
pub fn fuzziness(self, fuzziness: impl Into<Fuzziness>) -> Self
Maximum edit distance allowed for matching. See Fuzziness for valid values and more information. See Fuzziness in the match query for an example.
sourcepub fn max_expansions(self, max_expansions: u8) -> Self
pub fn max_expansions(self, max_expansions: u8) -> Self
Maximum number of terms to which the query will expand.
Defaults to 50
.
sourcepub fn prefix_length(self, prefix_length: u8) -> Self
pub fn prefix_length(self, prefix_length: u8) -> Self
Number of beginning characters left unchanged for fuzzy matching.
Defaults to 0
.
sourcepub fn transpositions(self, transpositions: bool) -> Self
pub fn transpositions(self, transpositions: bool) -> Self
Indicates whether edits include transpositions of two adjacent characters (ab → ba).
Defaults to true
sourcepub fn rewrite(self, rewrite: Rewrite) -> Self
pub fn rewrite(self, rewrite: Rewrite) -> Self
Method used to rewrite the query. For valid values and more information, see the rewrite parameter.
sourcepub fn boost<B>(self, boost: B) -> Self where
B: TryInto<Boost>,
pub fn boost<B>(self, boost: B) -> Self where
B: TryInto<Boost>,
Floating point number used to decrease or increase the
relevance scores
of a query. Defaults to 1.0
.
You can use the boost parameter to adjust relevance scores for searches containing two or more queries.
Boost values are relative to the default value of 1.0
.
A boost value between 0 and 1.0
decreases the relevance score.
A value greater than 1.0
increases the relevance score.
Trait Implementations
sourceimpl Clone for FuzzyQuery
impl Clone for FuzzyQuery
sourcefn clone(&self) -> FuzzyQuery
fn clone(&self) -> FuzzyQuery
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for FuzzyQuery
impl Debug for FuzzyQuery
sourceimpl From<FuzzyQuery> for Query
impl From<FuzzyQuery> for Query
sourcefn from(q: FuzzyQuery) -> Self
fn from(q: FuzzyQuery) -> Self
Converts to this type from the input type.
sourceimpl From<FuzzyQuery> for Option<Query>
impl From<FuzzyQuery> for Option<Query>
sourcefn from(q: FuzzyQuery) -> Self
fn from(q: FuzzyQuery) -> Self
Converts to this type from the input type.
sourceimpl From<FuzzyQuery> for Queries
impl From<FuzzyQuery> for Queries
sourcefn from(q: FuzzyQuery) -> Self
fn from(q: FuzzyQuery) -> Self
Converts to this type from the input type.
sourceimpl PartialEq<FuzzyQuery> for FuzzyQuery
impl PartialEq<FuzzyQuery> for FuzzyQuery
sourcefn eq(&self, other: &FuzzyQuery) -> bool
fn eq(&self, other: &FuzzyQuery) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &FuzzyQuery) -> bool
fn ne(&self, other: &FuzzyQuery) -> bool
This method tests for !=
.
sourceimpl PartialEq<FuzzyQuery> for Query
impl PartialEq<FuzzyQuery> for Query
sourceimpl PartialEq<Query> for FuzzyQuery
impl PartialEq<Query> for FuzzyQuery
sourceimpl Serialize for FuzzyQuery
impl Serialize for FuzzyQuery
impl StructuralPartialEq for FuzzyQuery
Auto Trait Implementations
impl RefUnwindSafe for FuzzyQuery
impl Send for FuzzyQuery
impl Sync for FuzzyQuery
impl Unpin for FuzzyQuery
impl UnwindSafe for FuzzyQuery
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