# Java API multi query

**URL:** <https://discuss.elastic.co/t/java-api-multi-query/13267>\
**Category:** Elasticsearch\
**Created:** [August 20, 2013, 9:42am UTC](https://discuss.elastic.co/t/java-api-multi-query/13267 "2013-08-20T09:42:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![oreno](https://avatars.discourse-cdn.com/v4/letter/o/b4bc9f/32.png) [@oreno](https://discuss.elastic.co/u/oreno)\
**Post date:** [August 20, 2013, 9:42am UTC](https://discuss.elastic.co/t/java-api-multi-query/13267/1 "2013-08-20T09:42:43Z")

</div>

Hi,  
1.while executing 400 request with multi query I'm getting EsRejectedExecutionException on the last response in the responses array.  
I read the next post explaining how to handle it by setting thread pool size = -1, but this is already the default value. Any ideas on how to increase the amount of parallel requests that ES can handle?

[http://jontai.me/blog/2013/06/esrejectedexecutionexception-rejected-execution-of-messagechannelhandler-requesthandler/](http://jontai.me/blog/2013/06/esrejectedexecutionexception-rejected-execution-of-messagechannelhandler-requesthandler/)

2.Also, I would like to know if there's a way of improving the performance of MultiSearchRequestBuilder.execute(), I'm getting results indicating that the requests are not running exactly in parallel, and there's appear to be some overhead that I'd like to improve.  
for example: I'm running 20 request that each take 120 -500 milliseconds, but the multi request takes almost 4000 milliseconds to return? and I have to get under a second. any ideas?

Thanks in advanced,

Oren

---

<div class="post-metadata">

**Author:** ![oreno](https://avatars.discourse-cdn.com/v4/letter/o/b4bc9f/32.png) [@oreno](https://discuss.elastic.co/u/oreno)\
**Post date:** [August 21, 2013, 12:19pm UTC](https://discuss.elastic.co/t/java-api-multi-query/13267/2 "2013-08-21T12:19:55Z")

</div>

Solved by adding initial thread pool size to elasticsearch.yml configuration file:

# Search pool

threadpool.search.size: 80

---

<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, 2:20am UTC](https://discuss.elastic.co/t/java-api-multi-query/13267/3 "2017-07-06T02:20:21Z")

</div>


