# Client.prepareGet() vs client.get()

**URL:** <https://discuss.elastic.co/t/client-prepareget-vs-client-get/6200>\
**Category:** Elasticsearch\
**Created:** [December 20, 2011, 9:12pm UTC](https://discuss.elastic.co/t/client-prepareget-vs-client-get/6200 "2011-12-20T21:12:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dawi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dawi/32/2439_2.png) [@dawi](https://discuss.elastic.co/u/dawi)\
**Post date:** [December 20, 2011, 9:12pm UTC](https://discuss.elastic.co/t/client-prepareget-vs-client-get/6200/1 "2011-12-20T21:12:03Z")

</div>

Hi together,

the interface org.elasticsearch.client.Client provides methods to execute  
requests (e.g. index(), delete(), get(), ...) and it also provides prepare  
methods which return builder instances which can be used to build and  
execute requests.

My question is which of both is the prefered way?  
What for example is the main difference between:

> client.prepareGet().setIndex(index).setId("123").execute().actionGet();  
> client.get(Requests.getRequest(index).id("123")).actionGet();

Or is it just a matter of taste?

Regards, Daniel

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [December 21, 2011, 3:37am UTC](https://discuss.elastic.co/t/client-prepareget-vs-client-get/6200/2 "2011-12-21T03:37:09Z")

</div>

Taste. Historically, the "get" was first introduced, and then the  
prepareGet was added.

On Tue, Dec 20, 2011 at 11:12 PM, dawi [d.wilmer.1980@googlemail.com](mailto:d.wilmer.1980@googlemail.com) wrote:

> Hi together,
> 
> the interface org.elasticsearch.client.Client provides methods to execute  
> requests (e.g. index(), delete(), get(), ...) and it also provides prepare  
> methods which return builder instances which can be used to build and  
> execute requests.
> 
> My question is which of both is the prefered way?  
> What for example is the main difference between:
> 
> > client.prepareGet().setIndex(index).setId("123").execute().actionGet();  
> > client.get(Requests.getRequest(index).id("123")).actionGet();
> 
> Or is it just a matter of taste?
> 
> Regards, Daniel

---

<div class="post-metadata">

**Author:** ![dawi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dawi/32/2439_2.png) [@dawi](https://discuss.elastic.co/u/dawi)\
**Post date:** [December 21, 2011, 7:54am UTC](https://discuss.elastic.co/t/client-prepareget-vs-client-get/6200/3 "2011-12-21T07:54:03Z")

</div>

Ok, thanks, for the info.

---

<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, 3:44am UTC](https://discuss.elastic.co/t/client-prepareget-vs-client-get/6200/4 "2017-07-06T03:44:45Z")

</div>


