'When querying with query_string what does fuzzy number or fuzzy AUTO means?
I read the documentation of (https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html) and still don't understand the following example:
GET /_search
{
"query": {
"bool": {
"must": [{
"query_string": {
"query": "1~central OR 0~park",
"default_field": "content"
}},
{"query_string": {
"query": "park~AUTO",
"quote_field_suffix": ".exact",
"fields": ["content"]
}}]
}}}
In the first
query_string: I'm not sure I understand what is the meaning of1~? I read aboutDamerau–Levenshtein distance, and still not sure I understand it correcly:1.1 what it the meaning of the number before
~? (1~, 0~, 2~)...?1.2 if the index contains:
CentralorcntrlorcenterorCentral, does the query finds this results with "1~central"?In the second
query_stringwhat is the meaing of AUTO ? (park~AUTO)
Solution 1:[1]
To apply fuzzy search along with query_string, you need to replace "query": "1~central OR 0~park" with "query": "central~1 OR park~0".
The search term will be at first and then you can use fuzzy operator after that (~), to implement fuzziness.
Refer to this part of documentation
The query string and the fuzziness parameter use the Damerau-Levenshtein distance to find the terms.
cntrl~1 means that the search terms will match the original document containing central, only if the edit distance equals 1.
Edit distance here means that the search term will match the original term, either by adding, deleting, or transposing the characters once, i.e. the original term should be restored in 1 step.
For Example:
The original term is central
cntrl -> centrl -> central (2 steps, so this will not match with (~1))
centrl -> central (1 step so this will match with (~1))
And in the case of AUTO, the following rule is applied
Generates an edit distance based on the length of the term. Low and high distance arguments may be optionally provided AUTO:[low],[high]. If not specified, the default values are 3 and 6, equivalent to AUTO:3,6 that make for lengths:
0..2 Must match exactly
3..5 One edit allowed
5 Two edits allowed
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ESCoder |

