Inconsistent completion suggester results size

Hello,

I am getting weird behaviour with the number of results returned by the Completion Suggester.

I have the following request body for example:

"suggest": {
  "title": {
    "prefix": "ja",
    "completion": {
      "field": "suggest",
      "size": 10
    }
  }
}

If the index has only 1 shard ("number_of_shards": 1), I sometimes get the size I specify, and sometimes less, depending on my luck.

For example, for a specific search I know for fact there are +50 matches, but if I use size=10 I get 9 or 10, and size=30 randomly returns 19 or 30.

If I increase the number of shards of this index, it starts behaving correctly and returns all the available results while respecting the size parameter, i.e. if I pass 30 for the size, I get back 30 results back. But if it's only 1 shard, things are quite random.

I would like to understand the reason why this happens before I just increase the number of shards. Especially that according to the documentation, it is recommended to use a single shard:

"To get best performance for completions, it is recommended to index completions into a single shard index"
Suggesters | Elasticsearch Guide [8.11] | Elastic

I am using v7.12.

2 Likes

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