Autosuggestion for integer not working in elastic search

(Rahul Ranjan) #1

I am using the Completion Suggesters as following. There is an issue for numeric autosuggest

index : { "_index": "mysuggestors", "_type": "suggest", "_id": "584a4455", "_score": 1, "_source": { "name": "Test 100AH 200 Title", "suggest": { "input": [ "Test", "100AH", "200", "100", "200 Title", "Titl", ], "output": "Test 100AH 200 Title", "payload": { "id": "584a4455" }, "weight": 10 } } }

case 1. autosuggest query :

{"suggestions": { "text": "100", "completion": {"field": "suggest"} }}

response : empty response

case 2. autosuggest query :

{"suggestions": { "text": "100A", "completion": {"field": "suggest"} }}

response : valid response

case 3. autosuggest query :

{"suggestions": { "text": "Tes", "completion": {"field": "suggest"} }}

response : valid response

(Alexander Reelsen) #2


this might stem from using the simple analyzer in the completion suggester. You can change the configuration in the mapping if you need to.


(Rahul Ranjan) #3

Hi ,
I am newbie to elastic search.. what i need to use instead of simple analyzer?

currently my analyzer is
index_analyzer simple
search_analyzer simple

(Christoph) #4


the "standard" analyzer might work for your simple example, however be sure to get familiar with how analyzers work before proceeding to using this on any larger amount of data, otherwise you might need to reindex later.

The problem with the "simple" analyzer is that it breaks text into terms whenever it encounters a character which is not a letter, so "100" will just end up as an empty string. You can check the behaviour of the build in analyzers with the "_analyze" endpoint to understand this better:

POST _analyze
  "analyzer": "simple",
  "text": "100"


  "tokens": []
POST _analyze
  "analyzer": "standard",
  "text": "100"


  "tokens": [
      "token": "100",
      "start_offset": 0,
      "end_offset": 3,
      "type": "<NUM>",
      "position": 0

(system) #5

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.