Getting uniform results from ES

I would like to get flat and uniform results from my ES index. I have 3 different types of documents in one index and when user types search query I want to return up to 10 documents of each document type even if results won't be relevant. Currently, I get a top containing only documents with certain type.

For example: for input "foo" I want to get something like:
1 doctype: 1 text: foo
2 doctype: 1 text: foo bar
11 doctype: 2 text: foo baz
12 doctype: 2 text: bar foo bar
21 doctype: 3 text: foo foo
22 doctype: 3 text: foo bar baz

I could parallel my query to 3 ES requests with filters by different document types and combine them in my backend but, I think it will hit the performance, because these user requests are too frequent.
Also, I've found a feature, and maybe it is the solution.

_msearch is probably the best option here.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.