My elasticsearch documents have a field Name
with entries like:
Samsung Galaxy S3
Samsung Galaxy Ace Duos 3
Samsung Galaxy Duos 3
Samsung Galaxy S2
Samsung Galaxy S (I9000)
On querying this field with the following query (notice the space between "s" and "3"):
{
"query": {
"match": {
"Name": {
"query": "galaxy s 3",
"fuzziness": 2,
"prefix_length": 1
}
}
}
}
It returns "Samsung Galaxy Duos 3"
as a relevant result, and not "Samsung Galaxy S3"
.
The pattern I notice for such a task is to disregard the space between any number and any single alphabetical character, and make the query. For example then, "I-phone 5s"
should also be returned by "I-phone 5 s"
.
Is there a nice way to accomplish this?