ElasticSearch get _id
When executing a search, you get back an object SearchResponse. By calling the method getHits() you get back a list of objects of type SearchHit. This object has a method id().
SearchResponse searchResponse = client.prepareSearch().setQuery(matchAllQuery()).get();for (SearchHit hit : searchResponse.getHits()) { String yourId = hit.id();}