Re: Get the last entry from each of multiple types

2015-03-23 Thread Roman Parkhunovsky
Jingzhao Ou, do you state that you successfully combined msearch with the query containing aggregations (like in your example)? How should the query be constructed then to prevent "msearch approach is not accepting normal JSON payloads"? Could you please post a working msearch API call example?

Re: Get the last entry from each of multiple types

2014-09-19 Thread Jingzhao Ou
Hi, David, Thanks a lot for your prompt help. I got both approaches working, which is very exciting. I prefer the top_hits aggregation approach. The msearch approach is not accepting normal JSON payloads, which makes things a bit harder for processing in Javascript. My query payload is shown

Re: Get the last entry from each of multiple types

2014-09-19 Thread David Pilato
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/guid

Get the last entry from each of multiple types

2014-09-19 Thread Jingzhao Ou
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 que