# Where is the callback function executed for searchAsync method

**URL:** <https://discuss.elastic.co/t/where-is-the-callback-function-executed-for-searchasync-method/283674>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [September 8, 2021, 2:22pm UTC](https://discuss.elastic.co/t/where-is-the-callback-function-executed-for-searchasync-method/283674 "2021-09-08T14:22:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fatcloud](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fatcloud/32/93873_2.png) [@fatcloud](https://discuss.elastic.co/u/fatcloud)\
**Post date:** [September 8, 2021, 2:22pm UTC](https://discuss.elastic.co/t/where-is-the-callback-function-executed-for-searchasync-method/283674/1 "2021-09-08T14:22:44Z")

</div>

Hi, I'm wondering where the callback function is executed when using searchAsync: [Search API | Java REST Client [7.14] | Elastic](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-search.html#java-rest-high-search-async)  
Is there some thread pool for the es client?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [September 13, 2021, 3:07pm UTC](https://discuss.elastic.co/t/where-is-the-callback-function-executed-for-searchasync-method/283674/2 "2021-09-13T15:07:41Z")

</div>

If you follow the `RestClientBuilder` class, you see that you can pass a custom `ThreadFactory`to the `HttpAsyncClientBuilder` that is used to start an additional thread.

See [https://github.com/elastic/elasticsearch/blob/master/client/rest/src/main/java/org/elasticsearch/client/RestClientBuilder.java#L334](https://github.com/elastic/elasticsearch/blob/master/client/rest/src/main/java/org/elasticsearch/client/RestClientBuilder.java#L334)

Hope this helps!

---

<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:** [October 11, 2021, 3:08pm UTC](https://discuss.elastic.co/t/where-is-the-callback-function-executed-for-searchasync-method/283674/3 "2021-10-11T15:08:08Z")

</div>

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