# Merging multiple queries

**URL:** <https://discuss.elastic.co/t/merging-multiple-queries/306099>\
**Category:** Elasticsearch\
**Created:** [June 1, 2022, 9:29am UTC](https://discuss.elastic.co/t/merging-multiple-queries/306099 "2022-06-01T09:29:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Krishna\_Sai\_Nag\_G](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/krishna_sai_nag_g/32/80467_2.png) [@Krishna\_Sai\_Nag\_G](https://discuss.elastic.co/u/Krishna_Sai_Nag_G)\
**Post date:** [June 1, 2022, 9:29am UTC](https://discuss.elastic.co/t/merging-multiple-queries/306099/1 "2022-06-01T09:29:12Z")

</div>

I have 3 queries as following  
First query gives us the file name of the content we search.

First query  
GET all\_files/\_search?scroll=1m  
{  
"\_source": "file.filename",  
"query": {  
"match\_phrase": {  
"content": {  
"query": "rape"  
}  
}  
}  
}

Based on the file name i need the following fileds from multiple indices which is in second query.

2nd query

GET doc\_classification,doc\_to\_topic\_association,doc\_with\_similar\_names/\_search?scroll=1m  
{  
"\_source": ["classification\_name","file\_path","description","category","topic\_name","filename\_with\_location","similar\_filename","similar\_filename\_with\_location","similarity\_score","duplicate"],  
"query": {  
"terms": {  
"file\_name": [  
"TSUNE00020181210eeca0005v.docx",  
"PHILNA0020190425ef4p000jl.docx"  
]  
}  
}  
}

in second query, we got topic name. Based on the topic\_name we need keywords from another index as shown in third query

3rd query

GET topic\_to\_keywords\_monash/\_search?scroll=1m  
{  
"query": {  
"match\_phrase": {  
"topic\_name": {  
"query": "law"  
}  
}  
}  
}

I need all the 3 queries as single query, is it possible.  
Can anyone help me on this?

---

<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:** [June 1, 2022, 9:49pm UTC](https://discuss.elastic.co/t/merging-multiple-queries/306099/2 "2022-06-01T21:49:49Z")

</div>

> [@Krishna\_Sai\_Nag\_G](#):
>
> I need all the 3 queries as single query, is it possible.

It's not sorry to say.

---

<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:** [June 29, 2022, 9:50pm UTC](https://discuss.elastic.co/t/merging-multiple-queries/306099/3 "2022-06-29T21:50:12Z")

</div>

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