# Getting uniform results from ES

**URL:** <https://discuss.elastic.co/t/getting-uniform-results-from-es/253649>\
**Category:** Elasticsearch\
**Created:** [October 29, 2020, 7:06am UTC](https://discuss.elastic.co/t/getting-uniform-results-from-es/253649 "2020-10-29T07:06:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![IliaIsakhin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/iliaisakhin/32/75238_2.png) [@IliaIsakhin](https://discuss.elastic.co/u/IliaIsakhin)\
**Post date:** [October 29, 2020, 7:06am UTC](https://discuss.elastic.co/t/getting-uniform-results-from-es/253649/1 "2020-10-29T07:06:54Z")

</div>

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 [https://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-multi-search.html) feature, and maybe it is the solution.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [November 3, 2020, 12:23am UTC](https://discuss.elastic.co/t/getting-uniform-results-from-es/253649/2 "2020-11-03T00:23:10Z")

</div>

`_msearch` is probably the best option here.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 1, 2020, 12:23am UTC](https://discuss.elastic.co/t/getting-uniform-results-from-es/253649/3 "2020-12-01T00:23:12Z")

</div>

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