tt_Gantz
tt_Gantz

Reputation: 2936

Elastic Search get vs action get

What is the difference between elastic search get vs action get?

Is it just that one exposes the exceptions where as the other one handles them itself?

All the usage examples with elastic search that I see (in Java) use actionGet, i.e

SearchResponse response = client.prepareSearch().execute().actionGet();

Which one should I be using and when?

Upvotes: 1

Views: 1803

Answers (1)

Rahul
Rahul

Reputation: 16345

FromThe official javaDocs of actionGet()

Similar to {@link #get()}, just catching the {@link InterruptedException} and throwing * an {@link org.elasticsearch.ElasticsearchIllegalStateException} instead. Also catches * {@link java.util.concurrent.ExecutionException} and throws the actual cause instead.

It just provides a wrapper over Future#get(), catches InterruptedException, ExecutionException and wraps them into ElasticSearchException

Also, you can directly use client.prepareSearch().get() instead of client.prepareSearch().execute().actionGet() . It internally does the same.

Upvotes: 2

Related Questions