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§
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 moresource§impl Debug for FuzzyQuery
impl Debug for FuzzyQuery
source§impl From<FuzzyQuery> for MultiTermQuery
impl From<FuzzyQuery> for MultiTermQuery
source§fn from(q: FuzzyQuery) -> Self
fn from(q: FuzzyQuery) -> Self
source§impl From<FuzzyQuery> for Option<MultiTermQuery>
impl From<FuzzyQuery> for Option<MultiTermQuery>
source§fn from(q: FuzzyQuery) -> Self
fn from(q: FuzzyQuery) -> Self
source§impl From<FuzzyQuery> for Option<Query>
impl From<FuzzyQuery> for Option<Query>
source§fn from(q: FuzzyQuery) -> Self
fn from(q: FuzzyQuery) -> Self
source§impl From<FuzzyQuery> for Query
impl From<FuzzyQuery> for Query
source§fn from(q: FuzzyQuery) -> Self
fn from(q: FuzzyQuery) -> Self
source§impl IntoIterator for FuzzyQuery
impl IntoIterator for FuzzyQuery
§type Item = FuzzyQuery
type Item = FuzzyQuery
§type IntoIter = IntoIter<<FuzzyQuery as IntoIterator>::Item>
type IntoIter = IntoIter<<FuzzyQuery as IntoIterator>::Item>
source§impl PartialEq<FuzzyQuery> for MultiTermQuery
impl PartialEq<FuzzyQuery> for MultiTermQuery
source§impl PartialEq<FuzzyQuery> for Query
impl PartialEq<FuzzyQuery> for Query
source§impl PartialEq<MultiTermQuery> for FuzzyQuery
impl PartialEq<MultiTermQuery> for FuzzyQuery
source§impl PartialEq<Query> for FuzzyQuery
impl PartialEq<Query> for FuzzyQuery
source§impl PartialEq for FuzzyQuery
impl PartialEq for FuzzyQuery
source§impl Serialize for FuzzyQuery
impl Serialize for FuzzyQuery
impl StructuralPartialEq for FuzzyQuery
Auto Trait Implementations§
impl Freeze for FuzzyQuery
impl RefUnwindSafe for FuzzyQuery
impl Send for FuzzyQuery
impl Sync for FuzzyQuery
impl Unpin for FuzzyQuery
impl UnwindSafe for FuzzyQuery
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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)