I'm using the fuzzy search option in ElasticSearch. It's pretty cool.
But I came across an issue when doing search for values that have spaces. For example say I have two values:
"Pizza"
"Pineapple Pizza"
and I search for Pizza using this query:
client.search({
index: 'food_index',
body: {
query: {
fuzzy: {
name: {
value: "Pizza",
transpositions: true,
}
},
}
}
})
The values returned are:
"Pizza"
"Pineapple Pizza"
Which is expected. But if I enter in the value "Pineapple Pizza" in my query:
client.search({
index: 'food_index',
body: {
query: {
fuzzy: {
name: {
value: "Pineapple Pizza",
transpositions: true,
}
},
}
}
})
The values returned are:
""
Empty
Why is that? It should be an exact match. I'm contemplating switching all names that have spaces in them to underscores. So "Pineapple Pizza" would be "Pineapple_Pizza" (This solution works for me). But I'm asking this question as to hopefully finding a better alternative. What am I doing wrong here?