elasticsearch completion suggester returns only one suggestion when more than one matches

702 Views Asked by At

I created index definition with mapping:

PUT /test
{
  "mappings": {
    "properties" : {
      "suggest" : {
          "type" : "completion"
      }
    }
  }
}

and put some data into

PUT test/_doc/1?refresh
{
    "suggest" : {
        "input": ["lorem ipsum", "lorem dolor"]
    }
}

next I'm getting suggestions

POST test/_search?pretty
{
    "_source": false, 
    "suggest": {
        "test-suggest" : {
            "prefix" : "lorem",
            "completion" : { 
                "field" : "suggest"
            }
            
        }
    }
}

The problem is the result contains only one suggestion "lorem dolor"

{
...
  "suggest" : {
    "test-suggest" : [
      {
        "text" : "lorem",
        "offset" : 0,
        "length" : 5,
        "options" : [
          {
            "text" : "lorem dolor",
            "_index" : "test",
            "_type" : "_doc",
            "_id" : "1",
            "_score" : 1.0
          }
        ]
      }
    ]
  }
}

I would like to get all matching suggestions for this document which are: "lorem ipsum" and "lorem dolor". Is that possible using elasticsearch completion?

0

There are 0 best solutions below