Aggregate across doctype?

Is it possible to aggregate across doctype? What I'm wanting to do is given doctypes of 'people', 'bears', 'lions, a search for 'leo' would find, say, the top 10 hits in each doctype of 'people', 'bears', 'lions'. Alternatively, I could add a doctype field to each document, but that seems wasteful.

the problem is that you can not ask for a precise number of hist for each type, but you can use _msearch in msearch you can made 3 different request, one for each type in the same request HTTP. by this way you can be sure to have the same number of results at least for each type

Oh, nice, I hadn't thought of that, thanks for the suggestion!

I've run into a little snag with using _msearch. I realized that I also need suggest cross-doctype as well. Is there an equivalent for suggest?

i never tried with suggest but the _msearch have the "search_type" this give you the possibility to use par example the _count API so you can test to do something like :

{"index" : "test", "search_type" : "suggest"}
{"query" : {"match_all" : {}}, "from" : 0, "size" : 10}

keep me posted if that works @cching ! :wink:

I'll give that a try and post back. Thanks for your help!

Using search_type:"suggest" does not work:

{
"error": "ElasticsearchIllegalArgumentException[No search type for [suggest]]",
"status": 400
}

Neither does using the _msearch endpoint with something like:

{ "suggest" : { "my-suggest" : { "text" : "n", "completion" : { "field" : "suggest" } } } }

Thanks for the help, though, it's much appreciated. Guess I might have to make multiple requests manually.