# ES term suggestion: Results is difference when "size" change

**URL:** <https://discuss.elastic.co/t/es-term-suggestion-results-is-difference-when-size-change/74477>\
**Category:** Elasticsearch\
**Created:** [February 9, 2017, 9:16am UTC](https://discuss.elastic.co/t/es-term-suggestion-results-is-difference-when-size-change/74477 "2017-02-09T09:16:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![duc.duong](https://avatars.discourse-cdn.com/v4/letter/d/41988e/32.png) [@duc.duong](https://discuss.elastic.co/u/duc.duong)\
**Post date:** [February 9, 2017, 9:16am UTC](https://discuss.elastic.co/t/es-term-suggestion-results-is-difference-when-size-change/74477/1 "2017-02-09T09:16:51Z")

</div>

Hi all,

I'm using ES 1.6 and I faced an issue with term suggestion recently :

a. When I set "size" to 8, I got suggestions like "1, 2, 3, 4, 5, 6, 7, 8"  
b. When I set "size" to 10 or bigger, I got suggestions like "1, 3, 2, 4, 7, 6, 9, 10"

The results in both cases is correct but the order is difference, and in some case the results of (b) don't contains the results of (a)

Is it because of the way ES travel through shards ?  
I tried "preference" option but seem not worked for suggestion.  
I also set "shard\_size" to a high value but seem affect performance and not a complete solution ?

I want to keep the same order when "size" increase, do you have any suggestions or idea on this ?  
Thanks a lot.

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [February 9, 2017, 9:59am UTC](https://discuss.elastic.co/t/es-term-suggestion-results-is-difference-when-size-change/74477/2 "2017-02-09T09:59:24Z")

</div>

> [@duc.duong](#):
>
> I also set "shard\_size" to a high value

What would the high value be?

---

<div class="post-metadata">

**Author:** ![duc.duong](https://avatars.discourse-cdn.com/v4/letter/d/41988e/32.png) [@duc.duong](https://discuss.elastic.co/u/duc.duong)\
**Post date:** [February 9, 2017, 10:23am UTC](https://discuss.elastic.co/t/es-term-suggestion-results-is-difference-when-size-change/74477/3 "2017-02-09T10:23:04Z")

</div>

Hi,

It's x100 in my case, so for size=10 I'll set shard\_size to 1000

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [February 9, 2017, 10:25am UTC](https://discuss.elastic.co/t/es-term-suggestion-results-is-difference-when-size-change/74477/4 "2017-02-09T10:25:02Z")

</div>

Hmm. And what was the performance difference? Do you have other aggregations nested under these terms too?

---

<div class="post-metadata">

**Author:** ![duc.duong](https://avatars.discourse-cdn.com/v4/letter/d/41988e/32.png) [@duc.duong](https://discuss.elastic.co/u/duc.duong)\
**Post date:** [February 9, 2017, 10:36am UTC](https://discuss.elastic.co/t/es-term-suggestion-results-is-difference-when-size-change/74477/5 "2017-02-09T10:36:00Z")

</div>

It's slower not much, still good (~10% slower) but not cover all the case (so I'm trying other values). I dont have aggs nested too.

In general, "shard\_size" is the solution ? It's because I think increase it too much will affect performance, so I'm finding some workarounds.

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [February 9, 2017, 10:46am UTC](https://discuss.elastic.co/t/es-term-suggestion-results-is-difference-when-size-change/74477/6 "2017-02-09T10:46:20Z")

</div>

> [@duc.duong](#):
>
> In general, "shard\_size" is the solution ?

Yes.  
You can determine the potential for inaccuracy in a result using this: [Terms Aggregation | Elasticsearch Guide [1.6] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/1.6/search-aggregations-bucket-terms-aggregation.html#_calculating_document_count_error)  
If you decide you want 100% accurate doc\_counts for the top terms returned you can always make a second request passing them in a `terms` query to narrow the scope of things you are aggregating.

---

<div class="post-metadata">

**Author:** ![duc.duong](https://avatars.discourse-cdn.com/v4/letter/d/41988e/32.png) [@duc.duong](https://discuss.elastic.co/u/duc.duong)\
**Post date:** [February 9, 2017, 11:10am UTC](https://discuss.elastic.co/t/es-term-suggestion-results-is-difference-when-size-change/74477/7 "2017-02-09T11:10:10Z")

</div>

Wait a bit, are we discussing on suggestion (completion) in ES ?  
I faced that problem when using suggestion and try to return same results when "size" parameter increased.  
BTW the issue seem similar to your case.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 9, 2017, 11:10am UTC](https://discuss.elastic.co/t/es-term-suggestion-results-is-difference-when-size-change/74477/8 "2017-03-09T11:10:32Z")

</div>

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