They are nicer to be used, but the builders are just wrappers. For the search aspect, there is also a SearchSourceBuilder that builds the source (and is used internally in the SearchRequestBuilder API).
The RequestBuilders were added later in the lifespan of elasticsearch, and people should use those for simplicity. (the prepareXXX APIs).
On Friday, February 10, 2012 at 9:21 PM, Eric Jain wrote:
On Feb 9, 12:27 am, Shay Banon <kim...@gmail.com (http://gmail.com)> wrote:
Yes, all are the same. A and B are "really" the same (Requests is just a simple static factory), and C was added later on in the life of elasticsearch and the on I recommend (more readable).
For the record, there's also an option D: new
SearchRequestBuilder(client)... C and D can be more useful because
some of the builders have more fine-grained methods. For example,
client.prepareSearch(index) returns a SearchRequestBuilder, which has
methods like setQuery, addFacet, setSize etc.
Requests.searchRequest(index) on the other hand returns a
SearchRequest, which requires the same values to be set via a single
call to source(json).