CRUD operations

We will have a closer look into the API operations, the CRUD (create, retrieve, update, and delete document) commands. Let's begin from the retrieve document call.

Fetching documents

Let's begin from the retrieve document call. We've already seen the following example when we discussed API anatomy:

GetResponse response = client
.prepareGet("library", "book", "1")
.setFields("title", "_source")
.execute().actionGet();

While in preparation, after setting the index name, type name (may be null if we don't care what the type is), and identifier we will have the tool object. This builder object is an instance of org.elasticsearch.action.get.GetRequestBuilder and allows us to set the following additional information:

  • setFields(String): This ...

Get Mastering ElasticSearch now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.