How to merge the result after multi search, then I can sort them like sorting in queryDSL?


(yyh3011) #1

I have a multi search like:

{"index" : "news"}
{"query":{ "bool":{ "must":[{ "more_like_this_field" : { "content"
:{"like_text" : "James", "min_term_freq":1, "max_query_terms" : 12}} }, {
"match":{"topic":"Business"} }] }}, "from" : 0, "size" : 4}
{"index" : "news"}
{"query":{ "bool":{ "must":[{ "more_like_this_field" : { "content"
:{"like_text" : "James", "min_term_freq":1, "max_query_terms" : 12}} }, {
"match":{"topic":"Sport"} }] }}, "from" : 0, "size" : 2}

but the result is an array, I expect I can merge them, and sort them by
date and _score, is there a best way to do this?
Can I sort them like in ES, adding " "sort" : [ { "date" : {"order" :
"desc"} }]" ?

thanks
johnson

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/e402e2cd-3097-486b-a4f7-bc2864114f33%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(Adrien Grand) #2

Hi,

All that the multi-search can do is executing several search requests in a
single HTTP request. If you want to have merged results for both topics,
you either need to submit a single query that matches both topics (but
there is no guarantee that you will have 4 of them in the business topic
and 2 of them in the sport topic, the first thousand matches might just be
about business), or on client side.

On Tue, Apr 15, 2014 at 10:15 AM, yyh3011@gmail.com wrote:

I have a multi search like:

{"index" : "news"}
{"query":{ "bool":{ "must":[{ "more_like_this_field" : { "content"
:{"like_text" : "James", "min_term_freq":1, "max_query_terms" : 12}} },
{ "match":{"topic":"Business"} }] }}, "from" : 0, "size" : 4}
{"index" : "news"}
{"query":{ "bool":{ "must":[{ "more_like_this_field" : { "content"
:{"like_text" : "James", "min_term_freq":1, "max_query_terms" : 12}} },
{ "match":{"topic":"Sport"} }] }}, "from" : 0, "size" : 2}

but the result is an array, I expect I can merge them, and sort them by
date and _score, is there a best way to do this?
Can I sort them like in ES, adding " "sort" : [ { "date" : {"order" :
"desc"} }]" ?

thanks
johnson

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/e402e2cd-3097-486b-a4f7-bc2864114f33%40googlegroups.comhttps://groups.google.com/d/msgid/elasticsearch/e402e2cd-3097-486b-a4f7-bc2864114f33%40googlegroups.com?utm_medium=email&utm_source=footer
.

For more options, visit https://groups.google.com/d/optout.

--
Adrien Grand

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j4%3DnxdoUGC%3DsohKeTrg0Yej-5ivp91vO_c%3DZeJQMOXjAg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


(system) #3