# Elastic search multiple queries issue

**URL:** <https://discuss.elastic.co/t/elastic-search-multiple-queries-issue/49015>\
**Category:** Elasticsearch\
**Created:** [May 3, 2016, 6:50am UTC](https://discuss.elastic.co/t/elastic-search-multiple-queries-issue/49015 "2016-05-03T06:50:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hitesh\_Chavhan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hitesh_chavhan/32/43058_2.png) [@Hitesh\_Chavhan](https://discuss.elastic.co/u/Hitesh_Chavhan)\
**Post date:** [May 3, 2016, 6:50am UTC](https://discuss.elastic.co/t/elastic-search-multiple-queries-issue/49015/1 "2016-05-03T06:50:11Z")

</div>

I have 1 lakh individual names in one particular doc\_type  
{  
"name":"abc",  
"country":"Germany"  
}  
and so on.

I receive 50k names from a REST Api, but then to fetch country of these names I have to query ES 50K times which took lot of time and IO on servers.  
Also I need to filter the names based on country.  
For Ex. only Germany people to extract from 50K names.

Any better way to write such query.

---

<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:** [May 4, 2016, 1:12am UTC](https://discuss.elastic.co/t/elastic-search-multiple-queries-issue/49015/2 "2016-05-04T01:12:10Z")

</div>

Why not just filter on the country and then match that against the list of names?  
You'd have to do the second part in your code though, there's no way to do that in ES.

---

<div class="post-metadata">

**Author:** ![Hitesh\_Chavhan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hitesh_chavhan/32/43058_2.png) [@Hitesh\_Chavhan](https://discuss.elastic.co/u/Hitesh_Chavhan)\
**Post date:** [May 4, 2016, 10:01am UTC](https://discuss.elastic.co/t/elastic-search-multiple-queries-issue/49015/3 "2016-05-04T10:01:01Z")

</div>

Hi,

Thanks for that. It really is the solution that we can try.  
But this require processing on back-end, can we give ES an array of names and the ES could return json with name and country. Is this sort of queries supported in ES.

---

<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:** [May 4, 2016, 10:32am UTC](https://discuss.elastic.co/t/elastic-search-multiple-queries-issue/49015/4 "2016-05-04T10:32:38Z")

</div>

As long as the index has the user name and the country in the same document, yes.

---

<div class="post-metadata">

**Author:** ![Hitesh\_Chavhan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hitesh_chavhan/32/43058_2.png) [@Hitesh\_Chavhan](https://discuss.elastic.co/u/Hitesh_Chavhan)\
**Post date:** [May 4, 2016, 10:55am UTC](https://discuss.elastic.co/t/elastic-search-multiple-queries-issue/49015/5 "2016-05-04T10:55:04Z")

</div>

Yes thanks that worked for me.

---

<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:** [July 5, 2017, 10:54pm UTC](https://discuss.elastic.co/t/elastic-search-multiple-queries-issue/49015/6 "2017-07-05T22:54:03Z")

</div>


