# Search within differnt indices get same amount of documents

**URL:** https://discuss.elastic.co/t/search-within-differnt-indices-get-same-amount-of-documents/158323
**Category:** Elasticsearch
**Created:** [November 27, 2018, 10:56am UTC](https://discuss.elastic.co/t/search-within-differnt-indices-get-same-amount-of-documents/158323 "2018-11-27T10:56:59Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![super\_yang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/super_yang/32/38112_2.png) [@super\_yang](https://discuss.elastic.co/u/super_yang)
#### Post date: [November 27, 2018, 10:56am UTC](https://discuss.elastic.co/t/search-within-differnt-indices-get-same-amount-of-documents/158323/1 "2018-11-27T10:56:59Z")

</div>

Hello  
I want to got the same amount of documents from different indices within one query  
For Examples:  
two indices Company / Person, both have a field called "name"  
And I want to search all name match "smart", but I want got the same amount from Company and Person  
I want get the result like this [company1, company2, ..., Company5] AND [Person1, Person2, ..., Person5], as you see, 10Results with 5 Companys and 5 Persons  
Besides, I'm using es5.3

So Anyone have some ideas?  
Cheers

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [November 27, 2018, 11:23am UTC](https://discuss.elastic.co/t/search-within-differnt-indices-get-same-amount-of-documents/158323/2 "2018-11-27T11:23:45Z")

</div>

You can use the multisearch API and set the size for both queries to 5 may be?

---

<div class="post-metadata">

### Author: ![super\_yang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/super_yang/32/38112_2.png) [@super\_yang](https://discuss.elastic.co/u/super_yang)
#### Post date: [November 27, 2018, 11:37am UTC](https://discuss.elastic.co/t/search-within-differnt-indices-get-same-amount-of-documents/158323/3 "2018-11-27T11:37:05Z")

</div>

3x I'll have a try

---

<div class="post-metadata">

### Author: ![super\_yang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/super_yang/32/38112_2.png) [@super\_yang](https://discuss.elastic.co/u/super_yang)
#### Post date: [November 28, 2018, 7:18am UTC](https://discuss.elastic.co/t/search-within-differnt-indices-get-same-amount-of-documents/158323/4 "2018-11-28T07:18:04Z")

</div>

@dadoonet thanks for your kind  
I finally got the right result, my code like this

```
GET test-1/_msearch
{"index" : "company"}
{"query" : {"match_all" : {}},"size":3}
{"index" : "person"}
{"query" : {"match_all" : {}},"size":3}
```

---

<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 26, 2018, 7:18am UTC](https://discuss.elastic.co/t/search-within-differnt-indices-get-same-amount-of-documents/158323/5 "2018-12-26T07:18:09Z")

</div>

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