I know that there is a way to search multiple indexes/types.
I am wondering is there a way to pass max hits for each index/index type.
We are working on the grouped autocomplete , so would like to be able to make one call and then group results on the index type.
Thanks
Mikhail
hello @mgoncharov i had the same question but I have not found how to limit in the same query for eacht type/index, so i finaly use _msearch, and i had multiple search querys in the same request and each query had a different max hits, different index and type!
http://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html
Hi Camilo, thanks a lot for your answer..Ive just tried multi search api but it does not seem to work.
Here's the example:
This query works fine:
POST _msearch
{"index" : "apps", "type":"orders"}
{"query" : {"match_all" : {}}, "from" : 0, "size" : 5}
{"index" : "apps", "type":"quotes"}
{"query" : {"match_all" : {}}, "from" : 0, "size" : 5}
but this one fails:
POST _msearch
{"index" : "apps", "type":"orders"}
{"query": {"term" : { "ordered_quantity" : 5 }},
"from" : 0, "size" : 5},
{"index" : "apps", "type":"quotes"}
{"query" : {"match_all" : {}}, "from" : 0, "size" : 5}
with Json parse error but why ?
Thanks
Mikhail
Hello @mgoncharov , yes your problems come to this line, in msearch (as *bulk api) you need to send your request in one line, hear your from and size attribute are in a new line and also in the end of our line you have a comma, you don't need use a comma between lines, \r\n it's enough. that need to be something more like that :