简体   繁体   中英

Similar Entry in Elasticsearch

I posted to:

http://localhost:9200/cities/city/1

{
"zip": "84359",
"city": "Simbach"
}

Now i wanted to find Simpach which is exactly 2 letters wrong:

http://localhost:9200/cities/_search

{
    "query": {
       "fuzzy": {
           "city" : {
               "value" : "Simpdach",
               "fuzziness" : 30
           }

       }
    }

but i dont get any result. I already saw this entry on stackoverflow and i cant find out, what i am doing wrong:

Fuzzy string matching using Levenshtein algorithm in Elasticsearch

Check your mapping and make sure city field is analyzed. Something like:

PUT /fuzzy_products/product/_mapping
{
  "product": {
    "properties": {
      "name": {
        "type": "string",
        "analyzer": "simple
      }
    }
  }
}

Check "simple fuzzy match" section . I hope it will be helpful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM