Completionsuggestion not always returning the payload

(Paul van der Bijl) #1

What i'm trying to do is make an autocomplete textfield for which I use the completion suggestion function. My mapping looks as follows:

 "mappings": {
     "skill": {
        "properties": {
            "name": {"type":"string", "analyzer":"lowercase_analyzer"},
            "synonyms": {
                "type": "completion",
                "index_analyzer": "lowercase_analyzer",
                "search_analyzer": "lowercase_analyzer",
                "payloads": true

On of the documents looks as follows:

  "_index" : "keyword",
  "_type" : "skill",
  "_id" : "AVD2rCWBFAX-55AWS1O2",
  "_score" : 1.0,
  "_source":{"naam":"Java","synonyms":{"input":["Java", "Jaaava", "Jaffa"],"output":"Java","payload":{"id":"AVD2rCWBFAX-55AWS1O2"}}}

What I'm trying to accomplish is the suggest function to return the output and payload. So for example when "Ja" is entered as a text, one of the offered suggestion should be: output ("Java") and payload ("id":"AVD2rCWBFAX-55AWS1O2"). I always get the output returned, but only in about ten percent of the cases the payload is returned. So I sometimes do get a payload returned, but not always.

I'm communicating with my cluster via the Java Elasticsearch client and I also tried it with curl, but both didn't work.

The problem seems to be the combination of the length of the entered text and the punctuation (the _ and -) in the id, but I can't find any information anywhere on when the payload is returned and when it isn't. What I would like is that the payload is always returned.

An example of what I get returned looks as follows:

    "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  "skill" : [ {
    "text" : "java s",
    "offset" : 0,
    "length" : 6,
    "options" : [ {
      "text" : "Java SE",
      "score" : 2.0
    }, {
      "text" : "Java Server Pages (JSP)",
      "score" : 2.0
    }, {
      "text" : "Java Server Faces",
      "score" : 1.0,
    } ]
  } ]

(system) #2