2

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?

Paulo
  • 8,690
  • 5
  • 20
  • 34
Wojciech Wirzbicki
  • 3,887
  • 6
  • 36
  • 59
  • 1
    So in the documentation https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters.html#querying they state you can use `size`, and by default `size = 5`. BUT I tried to make your example work ... and I only got one results I tried using the provided example .... it failed too returning only one result. – Paulo Feb 02 '22 at 17:24
  • 2
    Ahhhhh I got it! So I believe we both misunderstood the documentation. It is made to retrieve documents based on tags. If my understanding is correct. A user will type, this kind of search is going to retrieve documents based on the provided text and suggest a tag. – Paulo Feb 02 '22 at 22:17
  • I still do not get it. How did you solve this? It seems a retarded problem. – Mihai Raulea Dec 20 '22 at 17:10

0 Answers0