May be multi search could help in that case? http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-multi-search.html#search-multi-search
Or may be a terms aggregation on _type field (you'll need to index it) and a top hits sub aggregation: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-metrics-top-hits-aggregation.html#search-aggregations-metrics-top-hits-aggregation -- David Pilato | Technical Advocate | elasticsearch.com david.pil...@elasticsearch.com @dadoonet | @elasticsearchfr | @scrutmydocs Le 19 septembre 2014 à 22:29:07, Jingzhao Ou (jingzhao...@gmail.com) a écrit: Hi, all, To get the last entry from two different types, I am doing GET localhost:9200/index/type1 { size: 1, sort: { id: 'desc' }, } GET localhost:9200/index/type2 { size: 1, sort: { id: 'desc' }, } For more efficient queries over multiple types, I want to combine the two queries into one by doing GET localhost:9200/index/type1,type2 { size: 2, sort: { id: 'desc' }, } However, this only gives me the last two samples from either type1 or type 2. If the last two samples both belong to type1, the combined query only returns two type1 samples, which is different from the two separate GET queries. Can any one give me some hints how to get this done? I appreciate your help! Best regards, Jingzhao -- 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 elasticsearch+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/64c5323f-9a5c-4c79-9c4e-8e8cad50607b%40googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- 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 elasticsearch+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/etPan.541c93fa.41b71efb.23d3%40MacBook-Air-de-David.local. For more options, visit https://groups.google.com/d/optout.