I'm using Jest as ElasticSearch client to search documents:
JestClient client = ...;
Search search = ...;
SearchResult searchResult = client.execute(search);
List<Hit<T, Void>> hits = searchResult.getHits(klass);
Each Hit
object looks like:
{"_index":"some_index","_type":"some_type","_id":"some_id","_score":2.609438,"_source":{"foo1":"bar1","foo2":"bar2"}}
While I can only find hit.source
method, it seems no hit.id
method.
Parse it as JSON object and retrieve key _id
's value is a way, but is there any API that can get the document id?
@JestId
it should be mapped directly – Julien C.