[[java-docs-multi-get]]
=== Multi Get API

The multi get API allows to get a list of documents based on their `index`, `type` and `id`:

[source,java]
--------------------------------------------------
MultiGetResponse multiGetItemResponses = client.prepareMultiGet()
    .add("twitter", "tweet", "1")           <1>
    .add("twitter", "tweet", "2", "3", "4") <2>
    .add("another", "type", "foo")          <3>
    .get();

for (MultiGetItemResponse itemResponse : multiGetItemResponses) { <4>
    GetResponse response = itemResponse.getResponse();
    if (response.isExists()) {                      <5>
        String json = response.getSourceAsString(); <6>
    }
}
--------------------------------------------------
<1> get by a single id
<2> or by a list of ids for the same index / type
<3> you can also get from another index
<4> iterate over the result set
<5> you can check if the document exists
<6> access to the `_source` field

For more information on the multi get operation, check out the REST
{ref}/docs-multi-get.html[multi get] docs.

