Get APIedit
The get API allows to get a typed JSON document from the index based on its id. The following example gets a JSON document from an index called twitter, under a type called tweet, with id valued 1:
GetResponse response = client.prepareGet("twitter", "tweet", "1").get();
For more information on the get operation, check out the REST get docs.
Multi Get APIedit
The multi get API allows to get a list of documents based on their index
, type
and id
:
MultiGetResponse multiGetItemResponses = client.prepareMultiGet()
.add("twitter", "tweet", "1")
.add("twitter", "tweet", "2", "3", "4")
.add("another", "type", "foo")
.get();
for (MultiGetItemResponse itemResponse : multiGetItemResponses) {
GetResponse response = itemResponse.getResponse();
if (response.isExists()) {
String json = response.getSourceAsString();
}
}
get by a single id | |
or by a list of ids for the same index / type | |
you can also get from another index | |
iterate over the result set | |
you can check if the document exists | |
access to the |
For more information on the multi get operation, check out the REST multi get docs.