0

Please help me with choosing ElasticSearch suggesting type.

I have ElasticSearch index with big amount of companies, which have names like: "JSC Some company", "JSC Another company" and so on.

The Completion suggester doesn't work because user prefer type: "Some co..." but suggester works only if user starts with "JSC Some co..."

Is there any way to create quick search during user typing?

I want to add my mapping example and suggest query example in order get question more clear:

curl -XPUT 'localhost:9200/tass_suggest_test/_mapping/company?pretty' -H 'Content-Type: application/json' -d'
{
   "company": {
            "properties": {
                "id": {
                    "type": "integer"
                },
                "inn": {
                    "type": "keyword"
                },
                "innSuggest" : {
                    "type" : "completion",
                    "analyzer": "whitespace"
                }
            }
        }
}
'

curl -XGET 'localhost:9200/tass_suggest_test/_suggest?pretty' -H 'Content-Type: application/json' -d'
{
    "company-suggest" : {
        "prefix" : "78200",
        "completion" : {
            "field" : "innSuggest"
        }
    }
}
'
Alex Zhulin
  • 1,239
  • 2
  • 22
  • 42

1 Answers1

0

You can try using an ngram filter in the following manner.

"filter": {
    "suggest_filter": {
         "type"    : "ngram",
         "min_gram": 2,
         "max_gram": 7
     }
},
"analyzer": {
    "suggest_analyzer": {
         "type": "custom",
         "tokenizer": "whitespace",
         "filter": ["lowercase", "suggest_filter"]
     }
}
user732456
  • 2,638
  • 2
  • 35
  • 49
  • Thank you, but I think that it is not what I'm looking for. I have in my type in my index field wirh type "completion". I use completion type because I want to use "_suggest" instead of "_query" in order to get near realtime answer from search engine. Could you give me example how can I use this filter and analyzer in "completion" field. – Alex Zhulin Sep 15 '17 at 14:39