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§
Source§impl FuzzyQuery
impl FuzzyQuery
pub fn serialize<__S>(
__self: &FuzzyQuery,
__serializer: __S,
) -> Result<__S::Ok, __S::Error>where
__S: Serializer,
Source§impl FuzzyQuery
impl FuzzyQuery
Sourcepub fn fuzziness<T>(self, fuzziness: T) -> Self
pub fn fuzziness<T>(self, fuzziness: T) -> 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<T>(self, boost: T) -> Selfwhere
T: AsPrimitive<f32>,
pub fn boost<T>(self, boost: T) -> Selfwhere
T: AsPrimitive<f32>,
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§
Source§impl Clone for FuzzyQuery
impl Clone for FuzzyQuery
Source§fn clone(&self) -> FuzzyQuery
fn clone(&self) -> FuzzyQuery
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more