Reputation: 1629
I struggle to perform a fuzzy search with Elasticsearch 7.10.
My request is the following:
{
"size": 5,
"from": 0,
"query": {
"fuzzy": {
"name": {
"value": "P2",
"fuzziness": "AUTO",
"prefix_length": 0,
"max_expansions": 50
}
}
},
"track_scores": false
}
While I have a record looking like:
{
"bookId": "book-2",
"name": "Programming #2",
"entries": 36
}
The name
is declared as {type: "text", fielddata: true}
, and, despite that, I have no result. Can you give me a hint regarding my mistake?
Upvotes: 0
Views: 67
Reputation: 14077
From docs:
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)
Your query "P2"
doesn't match any of these cases. You might achieve this kind of behavior by changing source data or implementing analyzers that handle these kinds of use cases.
Upvotes: 1