Is there a way in elasticsearch using JAVA API to get only the ids of the 
documents returned for a give query.

    SearchResponse sr = 
 esClient.prepareSearch(index).setSize(resultSize).setQuery(q).setScroll(new 
TimeValue(10000)).setQuery(fqb).setFetchSource(false).get();

but I get empty hits (`sr.getHits().hits[].length == 0`) althouh the total 
count of returned hits is 0 (`sr.getHits().getTotalHits == 2`). I 
understand that nothing is returned by elasticsearch because I set fetch 
source to false, but the ids should somehow be available. My current 
solution is:

    SearchResponse sr = 
 esClient.prepareSearch(index).setSize(resultSize).setQuery(q).setScroll(new 
TimeValue(10000)).setQuery(fqb).srb.setFetchSource("_id", null).get();

However I think that gets the _id field from source, and for speed I would 
like to avoid this if possible.

Thanks,
Ilija

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/089b670f-763c-4795-859a-720767d24a81%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to