# What is the maximum query length in the request body for the rest API of elasticsearch

**URL:** <https://discuss.elastic.co/t/what-is-the-maximum-query-length-in-the-request-body-for-the-rest-api-of-elasticsearch/139083>\
**Category:** Elasticsearch\
**Created:** [July 9, 2018, 6:02am UTC](https://discuss.elastic.co/t/what-is-the-maximum-query-length-in-the-request-body-for-the-rest-api-of-elasticsearch/139083 "2018-07-09T06:02:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jingyan](https://avatars.discourse-cdn.com/v4/letter/j/b19c9b/32.png) [@Jingyan](https://discuss.elastic.co/u/Jingyan)\
**Post date:** [July 9, 2018, 6:02am UTC](https://discuss.elastic.co/t/what-is-the-maximum-query-length-in-the-request-body-for-the-rest-api-of-elasticsearch/139083/1 "2018-07-09T06:02:49Z")

</div>

I want to use query DSL to query data against elasticsearch, the request like following:  
GET /index\_test/\_search  
{"size":5000,"timeout":"500ms","query":{"range":{"@timestamp":{"from":1530768660540,"to":1530769620540,"include\_lower":true,"include\_upper":true,"boost":1.0}}},"post\_filter":{"bool":{"must":[{"terms":{"testField1":["testvalue1","testvalue2"],"boost":1.0}},{"exists":{"field":"testField2","boost":1.0}},{"terms":{"testId":["ID1","ID2"],"boost":1.0}}],"adjust\_pure\_negative":true,"boost":1.0}},"sort":[{"@timestamp":{"order":"desc"}}]}

For the testId filed, I will using a long items to match . So I need to add a lot of values in the terms.  
like this:  
{"terms":{"testId":["ID1","ID2","ID3","ID4","ID5".........],"boost":1.0}}

So I want to know how many values I can add for the values of testId.  
And so I need to know how long the query length in the request body?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [July 9, 2018, 6:46am UTC](https://discuss.elastic.co/t/what-is-the-maximum-query-length-in-the-request-body-for-the-rest-api-of-elasticsearch/139083/2 "2018-07-09T06:46:01Z")

</div>

There is no fixed limit. Elasticsearch will accept request bodies up to several MB in size by default. As seem in [this thread](https://discuss.elastic.co/t/filter-with-millions-of-record/134561), large terms queries are likely to get slow as the list of terms grows though. You will need to benchmark to see exactly how many you can handle with acceptable query latencies.

---

<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 6, 2018, 6:46am UTC](https://discuss.elastic.co/t/what-is-the-maximum-query-length-in-the-request-body-for-the-rest-api-of-elasticsearch/139083/3 "2018-08-06T06:46:02Z")

</div>

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