# searchRequestBuilder.execute() vs searchRequestBuilder.execute().actionget()

**URL:** <https://discuss.elastic.co/t/searchrequestbuilder-execute-vs-searchrequestbuilder-execute-actionget/10444>\
**Category:** Elasticsearch\
**Created:** [January 21, 2013, 10:52pm UTC](https://discuss.elastic.co/t/searchrequestbuilder-execute-vs-searchrequestbuilder-execute-actionget/10444 "2013-01-21T22:52:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![john\_2](https://avatars.discourse-cdn.com/v4/letter/j/dc4da7/32.png) [@john\_2](https://discuss.elastic.co/u/john_2)\
**Post date:** [January 21, 2013, 10:52pm UTC](https://discuss.elastic.co/t/searchrequestbuilder-execute-vs-searchrequestbuilder-execute-actionget/10444/1 "2013-01-21T22:52:41Z")

</div>

Hi,

Could some one pls tell me the difference  
between searchRequestBuilder.execute() and  
searchRequestBuilder.execute().actionget()

I'm trying to execute a n Elastic Search query using the Java API.  
My query does a match all and then appends a filter to it and is executed  
using the below line of code:

\*long timeInMillisBefore = new GregorianCalendar().getTimeInMillis();  
\*  
\*SearchResponse response = searchRequestBuilder.execute().actionget()  
\*  
_long timeInMillisAfter = new GregorianCalendar().getTimeInMillis();_

The execution takes about 449 milliseconds if i do a \*timeInMillisAfter - \*_timeInMillisBefore  
._  
response.getTook() gives 12 milliseconds.

As i add more fields, about 332, the execution takes about 2462 seconds and  
response.getTook() gives 21 milliseconds.

Apparently its the execution of the actionGet() method that is taking so  
much time. I have no idea why this method takes so much time.  
Also, if this method is responsible for loading the JSON response in java  
objects, then i dont need tht. I can do with a JSON response as well.  
Could some one pls throw light on this.

Thanks  
John

--

---

<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:** [January 22, 2013, 5:51am UTC](https://discuss.elastic.co/t/searchrequestbuilder-execute-vs-searchrequestbuilder-execute-actionget/10444/2 "2013-01-22T05:51:23Z")

</div>

Took is the time used by Elasticsearch to run the query on all shards.  
The response need then to be send back to the user. I think this is the extra time you see.

Execute is asynchronous. ActionGet wait for the answer.

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 21 janv. 2013 à 23:52, john [john2roll2@gmail.com](mailto:john2roll2@gmail.com) a écrit :

Hi,

Could some one pls tell me the difference between searchRequestBuilder.execute() and searchRequestBuilder.execute().actionget()

I'm trying to execute a n Elastic Search query using the Java API.  
My query does a match all and then appends a filter to it and is executed using the below line of code:

long timeInMillisBefore = new GregorianCalendar().getTimeInMillis();  
SearchResponse response = searchRequestBuilder.execute().actionget()  
long timeInMillisAfter = new GregorianCalendar().getTimeInMillis();

The execution takes about 449 milliseconds if i do a timeInMillisAfter - timeInMillisBefore .  
response.getTook() gives 12 milliseconds.

As i add more fields, about 332, the execution takes about 2462 seconds and response.getTook() gives 21 milliseconds.

Apparently its the execution of the actionGet() method that is taking so much time. I have no idea why this method takes so much time.  
Also, if this method is responsible for loading the JSON response in java objects, then i dont need tht. I can do with a JSON response as well.  
Could some one pls throw light on this.

Thanks  
John

--

--

---

<div class="post-metadata">

**Author:** ![johnES](https://avatars.discourse-cdn.com/v4/letter/j/c5a1d2/32.png) [@johnES](https://discuss.elastic.co/u/johnES)\
**Post date:** [January 22, 2013, 3:50pm UTC](https://discuss.elastic.co/t/searchrequestbuilder-execute-vs-searchrequestbuilder-execute-actionget/10444/3 "2013-01-22T15:50:58Z")

</div>

Thanks David. That helped a lot.

---

<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:55am UTC](https://discuss.elastic.co/t/searchrequestbuilder-execute-vs-searchrequestbuilder-execute-actionget/10444/4 "2017-07-06T02:55:14Z")

</div>


