# Terms is not fetching the results if total number of terms is more

**URL:** <https://discuss.elastic.co/t/terms-is-not-fetching-the-results-if-total-number-of-terms-is-more/91598>\
**Category:** Elasticsearch\
**Created:** [July 3, 2017, 7:27am UTC](https://discuss.elastic.co/t/terms-is-not-fetching-the-results-if-total-number-of-terms-is-more/91598 "2017-07-03T07:27:26Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![venkat2758](https://avatars.discourse-cdn.com/v4/letter/v/45deac/32.png) [@venkat2758](https://discuss.elastic.co/u/venkat2758)\
**Post date:** [July 3, 2017, 7:27am UTC](https://discuss.elastic.co/t/terms-is-not-fetching-the-results-if-total-number-of-terms-is-more/91598/1 "2017-07-03T07:27:26Z")

</div>

I am tring to filter the data using Elasticsearch terms query.I am passing morethan 300000 inputs to the terms query.Finally it ended up by showing the memory issue.

How can i resolve this issue.  
Please help.

Thanks in Advance

---

<div class="post-metadata">

**Author:** ![xavierfacq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xavierfacq/32/8744_2.png) [@xavierfacq](https://discuss.elastic.co/u/xavierfacq)\
**Post date:** [July 3, 2017, 8:01am UTC](https://discuss.elastic.co/t/terms-is-not-fetching-the-results-if-total-number-of-terms-is-more/91598/2 "2017-07-03T08:01:47Z")

</div>

> [@venkat2758](#):
>
> I am passing morethan 300000 inputs to the terms query

afaik TermsQuery are limited to 1024 terms. Loop over your terms divided by group of 1024, and make a multirequest.

---

<div class="post-metadata">

**Author:** ![venkat2758](https://avatars.discourse-cdn.com/v4/letter/v/45deac/32.png) [@venkat2758](https://discuss.elastic.co/u/venkat2758)\
**Post date:** [July 3, 2017, 11:22am UTC](https://discuss.elastic.co/t/terms-is-not-fetching-the-results-if-total-number-of-terms-is-more/91598/3 "2017-07-03T11:22:31Z")

</div>

ok.

Is it right decision by divinding the total 300000 terms spliting and excuting there will be multiple queries triggred to elasticsearch.

Does by increasing the count index.query.bool.max\_clause\_count: 1000240 does it help ful any way

thanks

---

<div class="post-metadata">

**Author:** ![venkat2758](https://avatars.discourse-cdn.com/v4/letter/v/45deac/32.png) [@venkat2758](https://discuss.elastic.co/u/venkat2758)\
**Post date:** [July 4, 2017, 8:07am UTC](https://discuss.elastic.co/t/terms-is-not-fetching-the-results-if-total-number-of-terms-is-more/91598/4 "2017-07-04T08:07:19Z")

</div>

Thank you very much,It worked.

But my concern is there would be too many queries to [elasticsearch.Is](http://elasticsearch.Is) it fine?  
It cannot impact any performance i belive ?  
please suggest.

Thanks .

---

<div class="post-metadata">

**Author:** ![xavierfacq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xavierfacq/32/8744_2.png) [@xavierfacq](https://discuss.elastic.co/u/xavierfacq)\
**Post date:** [July 4, 2017, 9:22am UTC](https://discuss.elastic.co/t/terms-is-not-fetching-the-results-if-total-number-of-terms-is-more/91598/5 "2017-07-04T09:22:14Z")

</div>

> [@venkat2758](#):
>
> is there would be too many queries to elasticsearch

Hi,

Yes, It may, because 300k / 1024 = 292 queries running.  
You realy need to send 300k of values ? it cannot be a range for exemple ?

bye,  
Xavier

---

<div class="post-metadata">

**Author:** ![venkat2758](https://avatars.discourse-cdn.com/v4/letter/v/45deac/32.png) [@venkat2758](https://discuss.elastic.co/u/venkat2758)\
**Post date:** [July 4, 2017, 10:00am UTC](https://discuss.elastic.co/t/terms-is-not-fetching-the-results-if-total-number-of-terms-is-more/91598/6 "2017-07-04T10:00:13Z")

</div>

Thanks For reply.

No we cannot use Range query.The reason is i have to fetch for the selected data only .I need to [fetch.So](http://fetch.So) we are using terms query.

That is the reason we using terms query.does it may have any performance issue.

Thanks  
Venkat

---

<div class="post-metadata">

**Author:** ![xavierfacq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xavierfacq/32/8744_2.png) [@xavierfacq](https://discuss.elastic.co/u/xavierfacq)\
**Post date:** [July 4, 2017, 3:36pm UTC](https://discuss.elastic.co/t/terms-is-not-fetching-the-results-if-total-number-of-terms-is-more/91598/7 "2017-07-04T15:36:54Z")

</div>

> [@venkat2758](#):
>
> does it may have any performance issue.

I cannot tell you if yes or no, it depends of your dataset, etc..., it's just going to make lot of queries.

bye,  
Xavier

---

<div class="post-metadata">

**Author:** ![venkat2758](https://avatars.discourse-cdn.com/v4/letter/v/45deac/32.png) [@venkat2758](https://discuss.elastic.co/u/venkat2758)\
**Post date:** [July 5, 2017, 7:57am UTC](https://discuss.elastic.co/t/terms-is-not-fetching-the-results-if-total-number-of-terms-is-more/91598/8 "2017-07-05T07:57:36Z")

</div>

Thanks for the reply.

Can i increase the Default max clause count by using the below config change in the elasticsearch cofig file.  
index.query.bool.max\_clause\_count: 10240.

By this i can reduce my queries by 10times i.e to 292 queries to 29 or 30 queries.  
suggest is that it can be good approach?

Thanks  
Venkat

---

<div class="post-metadata">

**Author:** ![xavierfacq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xavierfacq/32/8744_2.png) [@xavierfacq](https://discuss.elastic.co/u/xavierfacq)\
**Post date:** [July 5, 2017, 6:08pm UTC](https://discuss.elastic.co/t/terms-is-not-fetching-the-results-if-total-number-of-terms-is-more/91598/9 "2017-07-05T18:08:27Z")

</div>

> [@venkat2758](#):
>
> By this i can reduce my queries by 10times i.e to 292 queries to 29 or 30 queries.  
> suggest is that it can be good approach?

Hi,

I understand, but I cannot answer to this question.  
cc @dadoonet @warkolm any idea ?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 5, 2017, 9:12pm UTC](https://discuss.elastic.co/t/terms-is-not-fetching-the-results-if-total-number-of-terms-is-more/91598/10 "2017-07-05T21:12:38Z")

</div>

I dunno. @jpountz can hopefully help.

---

<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:** [August 2, 2017, 9:12pm UTC](https://discuss.elastic.co/t/terms-is-not-fetching-the-results-if-total-number-of-terms-is-more/91598/11 "2017-08-02T21:12:44Z")

</div>

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