# Java API related questions

**URL:** <https://discuss.elastic.co/t/java-api-related-questions/5201>\
**Category:** Elasticsearch\
**Created:** [August 19, 2011, 3:43pm UTC](https://discuss.elastic.co/t/java-api-related-questions/5201 "2011-08-19T15:43:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pawel\_Konieczny](https://avatars.discourse-cdn.com/v4/letter/p/dc4da7/32.png) [@Pawel\_Konieczny](https://discuss.elastic.co/u/Pawel_Konieczny)\
**Post date:** [August 19, 2011, 3:43pm UTC](https://discuss.elastic.co/t/java-api-related-questions/5201/1 "2011-08-19T15:43:58Z")

</div>

Hey!

While developing a wrapper for elasticsearch for my application I got  
a little confused with the asynchronous nature of the calls and the  
Java API. The API is really neat, but it somewhat suffers from  
ambiguity.

I think a few more examples with a full breakdown of each method would  
really help a lot in clarifying all doubts.  
Meanwhile I have some questions:

1. What does the execute() method on a request builder actually do?
2. What does the actionGet() method do?
3. If a resource is added to the indexer queue (if I understand  
correctly, that's what happens after executing the prepareIndex  
directive) is there anything that can do wrong with indexing later on?  
If so, how to find out?
4. What are index() and delete() methods for?

Cheers,  
Pawel

---

<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:** [August 22, 2011, 6:46pm UTC](https://discuss.elastic.co/t/java-api-related-questions/5201/2 "2011-08-22T18:46:04Z")

</div>

2011/8/19 Paweł Konieczny [koniecznypw@gmail.com](mailto:koniecznypw@gmail.com)

> Hey!
> 
> While developing a wrapper for elasticsearch for my application I got  
> a little confused with the asynchronous nature of the calls and the  
> Java API. The API is really neat, but it somewhat suffers from  
> ambiguity.
> 
> I think a few more examples with a full breakdown of each method would  
> really help a lot in clarifying all doubts.  
> Meanwhile I have some questions:
> 
> 1. What does the execute() method on a request builder actually do?

Returns a Future, which you can use to either block for a response, or add a  
listener to.

> 1. What does the actionGet() method do?

Blocks till the operation is executed and a response is returned.

> 1. If a resource is added to the indexer queue (if I understand  
> correctly, that's what happens after executing the prepareIndex  
> directive) is there anything that can do wrong with indexing later on?  
> If so, how to find out?

Calling prepareIndex (for example) does not do anything, calling execute  
causes that call to be executed, and you can use the returned Future to  
decide how to act on it. Calling actionGet makes it fully blocking call.

> 1. What are index() and delete() methods for?

Similar APIs to prepareIndex, just a different flavor. The one that returns  
a response is a blocking call, the one that accepts a listener is not.

> Cheers,  
> Pawel

---

<div class="post-metadata">

**Author:** ![Pawel\_Konieczny](https://avatars.discourse-cdn.com/v4/letter/p/dc4da7/32.png) [@Pawel\_Konieczny](https://discuss.elastic.co/u/Pawel_Konieczny)\
**Post date:** [August 23, 2011, 2:32pm UTC](https://discuss.elastic.co/t/java-api-related-questions/5201/3 "2011-08-23T14:32:58Z")

</div>

Hey!

Thanks for clarifying those issues, it all makes sense now. I think  
that some kind of Java API quick start tutorial would really help  
developers who stumble upon this great project and thus increase the  
number of production stories.  
The existing guide forces the user to dig deep, which isn't always the  
best way to learn something new.

Cheers,  
Pawel

On Aug 22, 8:46 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> 2011/8/19 Paweł Konieczny [konieczn...@gmail.com](mailto:konieczn...@gmail.com)
> 
> > Hey!
> 
> > While developing a wrapper for elasticsearch for my application I got  
> > a little confused with the asynchronous nature of the calls and the  
> > Java API. The API is really neat, but it somewhat suffers from  
> > ambiguity.
> 
> > I think a few more examples with a full breakdown of each method would  
> > really help a lot in clarifying all doubts.  
> > Meanwhile I have some questions:
> > 
> > 1. What does the execute() method on a request builder actually do?
> 
> Returns a Future, which you can use to either block for a response, or add a  
> listener to.
> 
> > 1. What does the actionGet() method do?
> 
> Blocks till the operation is executed and a response is returned.
> 
> > 1. If a resource is added to the indexer queue (if I understand  
> > correctly, that's what happens after executing the prepareIndex  
> > directive) is there anything that can do wrong with indexing later on?  
> > If so, how to find out?
> 
> Calling prepareIndex (for example) does not do anything, calling execute  
> causes that call to be executed, and you can use the returned Future to  
> decide how to act on it. Calling actionGet makes it fully blocking call.
> 
> > 1. What are index() and delete() methods for?
> 
> Similar APIs to prepareIndex, just a different flavor. The one that returns  
> a response is a blocking call, the one that accepts a listener is not.
> 
> > Cheers,  
> > Pawel

---

<div class="post-metadata">

**Author:** ![Andrej](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@Andrej](https://discuss.elastic.co/u/Andrej)\
**Post date:** [August 24, 2011, 8:28am UTC](https://discuss.elastic.co/t/java-api-related-questions/5201/4 "2011-08-24T08:28:46Z")

</div>

A few more examples or explanations would make life easier, for sure. I became a real fan of this project, but digging deeper not everything is selfexplaning (at least in my eyes) and looking at examples is helpfull anyway. Shay, have you ever considered setting up a Wiki so users could help you with documentation? I'm sure a lot of people would benefit from it. And maybe you could transfer parts back to your guide or javadoc?

---

<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:** [August 24, 2011, 6:24pm UTC](https://discuss.elastic.co/t/java-api-related-questions/5201/5 "2011-08-24T18:24:02Z")

</div>

The site is hosted on github, you can easily contribute to it:  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/community/contributing-site.html).

On Wed, Aug 24, 2011 at 11:28 AM, Andrej [andrej.rosenheinrich@unister.de](mailto:andrej.rosenheinrich@unister.de)wrote:

> A few more examples or explanations would make life easier, for sure. I  
> became a real fan of this project, but digging deeper not everything is  
> selfexplaning (at least in my eyes) and looking at examples is helpfull  
> anyway. Shay, have you ever considered setting up a Wiki so users could  
> help  
> you with documentation? I'm sure a lot of people would benefit from it. And  
> maybe you could transfer parts back to your guide or javadoc?
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/Java-API-related-questions-tp3268417p3280372.html](http://elasticsearch-users.115913.n3.nabble.com/Java-API-related-questions-tp3268417p3280372.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<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:56am UTC](https://discuss.elastic.co/t/java-api-related-questions/5201/6 "2017-07-06T03:56:08Z")

</div>


