Fuzzy lookup for query string on ElasticSearch Fuzzy lookup for query string on ElasticSearch elasticsearch elasticsearch

Fuzzy lookup for query string on ElasticSearch


You can either use the fuzzy query:

{    "fuzzy" : { "user" : "ki" }}

Or use the fuzziness factor in a match query. Another way to achieve what you want in your example is to use synonyms. With synonyms you can tell elasticsearch to store synonyms to your words along with the original words, e.g. gray will be stored as gray and grey.

Here is a in-depth description of the synonyms: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/analysis-synonym-tokenfilter.html


Another example of fuzzy search (if you gonna use it)

POST /IndexName/TypeName/_search?size=200{   "query": {      "fuzzy": {         "FieldName": {            "value": "gray",            "fuzziness": 2,            "prefix_length": 1,            "boost": 5         }      }   }}

for multi word search use fuzzy_like_this

POST /IndexName/TypeName/_search?size=200{   "query": {      "fuzzy_like_this": {         "fields": ["FieldName1","FieldName2"],         "like_text": "user query with +bool AND operators",         "max_query_terms": 12,         "fuzziness": 0.5      }   }}