Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ElasticSearch fuzzy query and case sensitivity

I've just started looking into ElasticSearch and had some questions on the fuzzy query. Let's say I had a document like this:

{ "name": "Frankie's Hot Dogs" }

Using the fuzzy query, if I searched using the following parameters, I'd receive no results:

"fuzzy": {
  "name": {
    "value": "FRANKIES",
    "fuzziness": 2
  }
}

Is this the expected behavior? I thought that since the field was defaulted to the Standard Analyzer that the name field would be tokenized and lowercased to something like:

["frankie's", "hot", "dogs"]

So wouldn't searching through a fuzzy query automatically lowercase your search terms? Or is this not the case?

Finally, does anyone have any suggestions on querying the data so that FRANKIES would actually return a hit?

Thanks in advance.

like image 767
Robert Avatar asked Dec 06 '25 03:12

Robert


1 Answers

Use fuzzy_like_this query

 "query": {
    "fuzzy_like_this" : {
        "fields" : ["name"],
        "like_text" : "FRANKIES"
    }
}
like image 142
Siddardha Budige Avatar answered Dec 09 '25 15:12

Siddardha Budige



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!