# Efficient query with a big input filter set?

**URL:** <https://discuss.elastic.co/t/efficient-query-with-a-big-input-filter-set/25114>\
**Category:** Elasticsearch\
**Created:** [July 8, 2015, 5:54am UTC](https://discuss.elastic.co/t/efficient-query-with-a-big-input-filter-set/25114 "2015-07-08T05:54:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![linlma](https://avatars.discourse-cdn.com/v4/letter/l/ec9cab/32.png) [@linlma](https://discuss.elastic.co/u/linlma)\
**Post date:** [July 8, 2015, 5:54am UTC](https://discuss.elastic.co/t/efficient-query-with-a-big-input-filter-set/25114/1 "2015-07-08T05:54:55Z")

</div>

Hello Elastic experts,

I have a simple index with 100M books and each book has an unique book ID (string). I have another 1M book IDs (the 1M book ID belongs to 100M book IDs), and my query is simple, I just want to retrieve the 1M books information stored in Elastic Search cluster by book IDs (kinds of filter the 100M books by the 1M book IDs).

My current concern is if I pass the 1M book ID in a single query, the query will be super huge JSON, will there be any problems? But to send 1M queries with each query a single book ID may be too much overhead of the # of queries? Any good solutions is appreciated.

thanks in advance,  
Lin

---

<div class="post-metadata">

**Author:** ![linlma](https://avatars.discourse-cdn.com/v4/letter/l/ec9cab/32.png) [@linlma](https://discuss.elastic.co/u/linlma)\
**Post date:** [July 11, 2015, 12:01am UTC](https://discuss.elastic.co/t/efficient-query-with-a-big-input-filter-set/25114/2 "2015-07-11T00:01:40Z")

</div>

Hi Elastic Search experts,

If any one could have any good advice, it will be great.

regards,  
Lin

---

<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:** [July 11, 2015, 7:17am UTC](https://discuss.elastic.co/t/efficient-query-with-a-big-input-filter-set/25114/3 "2015-07-11T07:17:52Z")

</div>

You propose two options - 1 query with a million terms or a million queries with a single term. The preferable option is somewhere between these two extremes eg a thousand queries each with a thousand terms.

---

<div class="post-metadata">

**Author:** ![linlma](https://avatars.discourse-cdn.com/v4/letter/l/ec9cab/32.png) [@linlma](https://discuss.elastic.co/u/linlma)\
**Post date:** [July 11, 2015, 7:30am UTC](https://discuss.elastic.co/t/efficient-query-with-a-big-input-filter-set/25114/4 "2015-07-11T07:30:18Z")

</div>

Thanks Mark,

I think the former will always have better performance?

BTW, do you know if there is a limit about how big request JSON could be?

regards,  
Lin

---

<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:** [July 6, 2017, 12:02am UTC](https://discuss.elastic.co/t/efficient-query-with-a-big-input-filter-set/25114/5 "2017-07-06T00:02:10Z")

</div>


