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

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

--

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 :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 21 janv. 2013 à 23:52, john 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

--

--

Thanks David. That helped a lot.