Fuzzy contains query with elasticSearch -


how can perform query fuzzy , contains on strings? let's have following document:

{ ... "name":"william shakespeare" ... }

i receive document following queries:

  1. "william" (will return williams)
  2. "willeam" (same 1)
  3. "william shake" (will return document contains "william shake"
  4. "wiliam sake" (same 3)
  5. "william shakespeare" / "william shakespeare" / "william shakespeer" (will return william shakespeare

i tried use ngram analyzer , fuzziness queries no success.

{   "settings": {     "analysis": {       "filter": {         "ngram_analyzer_filter": {           "type": "ngram",           "min_gram": 2,           "max_gram": 15         }       },       "analyzer": {         "ngram_analyzer": {           "type": "custom",           "tokenizer": "standard",           "filter": [             "lowercase",             "ngram_analyzer_filter"           ]         }       }     }   },   "mappings": {     "my_type": {       "properties": {         "name": {           "type": "string",           "analyzer": "ngram_analyzer",           "search_analyzer": "standard",           "fields": {             "raw": {               "type": "string",               "index": "not_analyzed"             }           }         }       }     }   } } 

my query:

{   "query": {     "multi_match": {       "query": "william shake",       "fields": [         "name.raw"       ],       "fuzziness": 2,       "minimum_should_match":2     }   } } 
  • it multi_match because search more 1 field.
  • tried use analyzed field or not_analyzed field.
  • tried use "type":"phrase"
  • elastic version 2.3.1

try below query.

{   'query': {     'multi_match': {       'fields':  [            "name.raw"          ],         'query': $scope.search.queryterm,         'fuzziness': 2,         'prefix_length': 1     }   } } 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -