June 2017
Beginner to intermediate
404 pages
8h 22m
English
Once the client is initialized, we will use the index API to index a JSON document. In this example, we will be using the transport client to index the document. To index, we have to use the prepareIndex method. All the operations using the client are asynchronous and will return a future:
Future<IndexResponse> future = client.prepareIndex("chapter4", "person", 1").setSource(document);
To make the operation synchronous, we can call the GET method as shown here:
IndexResponse response = client.prepareIndex("chapter4", "person", "1").setSource(document).get();
The following are the details of the preceding example:
The document to be indexed is set using the preceding ...
Read now
Unlock full access