# Help with terminate\_after returns more results than must

**URL:** <https://discuss.elastic.co/t/help-with-terminate-after-returns-more-results-than-must/211595>\
**Category:** Elasticsearch\
**Created:** [December 12, 2019, 8:29am UTC](https://discuss.elastic.co/t/help-with-terminate-after-returns-more-results-than-must/211595 "2019-12-12T08:29:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![AndriyImp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andriyimp/32/57480_2.png) [@AndriyImp](https://discuss.elastic.co/u/AndriyImp)\
**Post date:** [December 12, 2019, 8:29am UTC](https://discuss.elastic.co/t/help-with-terminate-after-returns-more-results-than-must/211595/1 "2019-12-12T08:29:54Z")

</div>

Hi All!

I have strange result when make my query request - on local all ok and works like expected, but on AWS haves issue - i set

**terminate\_after**

but it not works like expected, see attached screen.

data = response['hits']['hits']

params = elasticsearch query

 ![Screenshot%20from%202019-12-12%2010-23-45](https://us1.discourse-cdn.com/elastic/original/3X/5/8/5818ad611c3ff7f276c29b98c3c50c429ca94245.png)

any ideas why this give me **5 results insteed 1**??

Thanks!

---

<div class="post-metadata">

**Author:** ![abdon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abdon/32/9195_2.png) [@abdon](https://discuss.elastic.co/u/abdon)\
**Post date:** [December 12, 2019, 8:47am UTC](https://discuss.elastic.co/t/help-with-terminate-after-returns-more-results-than-must/211595/2 "2019-12-12T08:47:47Z")

</div>

`terminate_after` is per shard. My guess is that locally you're querying an index with 1 shard, while on AWS you're querying an index with 5 shards.

---

<div class="post-metadata">

**Author:** ![AndriyImp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andriyimp/32/57480_2.png) [@AndriyImp](https://discuss.elastic.co/u/AndriyImp)\
**Post date:** [December 12, 2019, 9:00am UTC](https://discuss.elastic.co/t/help-with-terminate-after-returns-more-results-than-must/211595/3 "2019-12-12T09:00:07Z")

</div>

m.... so main issue in indexing process? any ideas what parameter i need set (on idex or in search and what exact)?

---

<div class="post-metadata">

**Author:** ![abdon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abdon/32/9195_2.png) [@abdon](https://discuss.elastic.co/u/abdon)\
**Post date:** [December 12, 2019, 9:08am UTC](https://discuss.elastic.co/t/help-with-terminate-after-returns-more-results-than-must/211595/4 "2019-12-12T09:08:33Z")

</div>

When you [create an index](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html), you can provide a body with [settings](https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules.html#index-modules-settings). One of those settings is `number_of_shards`. Prior to version 7, this defaulted to 5. As of version 7 now, this defaults to 1. Maybe that's what you're seeing?

What is it you're trying to achieve exactly? If you only want to see one hit, you can use the `size` parameter instead of `terminate_after`.

---

<div class="post-metadata">

**Author:** ![AndriyImp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andriyimp/32/57480_2.png) [@AndriyImp](https://discuss.elastic.co/u/AndriyImp)\
**Post date:** [December 12, 2019, 9:16am UTC](https://discuss.elastic.co/t/help-with-terminate-after-returns-more-results-than-must/211595/5 "2019-12-12T09:16:26Z")

</div>

thank! you help me again! ))

---

<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:** [January 9, 2020, 9:16am UTC](https://discuss.elastic.co/t/help-with-terminate-after-returns-more-results-than-must/211595/6 "2020-01-09T09:16:29Z")

</div>

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