# MultiIndex query with sort and search filters different for each indices

**URL:** <https://discuss.elastic.co/t/multiindex-query-with-sort-and-search-filters-different-for-each-indices/234948>\
**Category:** Elasticsearch\
**Created:** [May 29, 2020, 3:26pm UTC](https://discuss.elastic.co/t/multiindex-query-with-sort-and-search-filters-different-for-each-indices/234948 "2020-05-29T15:26:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ArunVenkat](https://avatars.discourse-cdn.com/v4/letter/a/8797f3/32.png) [@ArunVenkat](https://discuss.elastic.co/u/ArunVenkat)\
**Post date:** [May 29, 2020, 3:26pm UTC](https://discuss.elastic.co/t/multiindex-query-with-sort-and-search-filters-different-for-each-indices/234948/1 "2020-05-29T15:26:35Z")

</div>

Hi Team,

Hope you are doing doing good!!!

Can you help me on this???

I need a MutiIndex search query, where I can sort the columns of each Indices and specify the Columns for each Indices(\_Source) and with filter condition for each indixes.

Say I have two indices Index1, Index2.  
Index1 has columns idIndex1, col1Index1, col2Index1  
Index2 has columns idIndex2, col1Index2, col2Index2  
GET index1,index2/\_search  
{  
"\_source":["col1Index1"]  
"aggs": {  
"index1,index2": {  
"terms": {  
"field": "{\_index}"  
}  
}  
},  
"query": {  
"bool": {  
"should": [  
{  
"bool": {  
"must": [  
{  
"match": {  
"idindex1": "1"  
}  
}  
],  
"filter": [  
{  
"terms": {  
"\_index": [  
"index1"  
]  
}  
}  
]  
}  
},  
{  
"bool": {  
"must": [  
{  
"match": {  
"idindex2": "2"  
}  
}  
],  
"filter": [  
{  
"terms": {  
"\_index": [  
"index2"  
]  
}  
}  
]  
}  
}

```
  ]
}

```

}  
}

Here this query is applying to both the indices with same output columns.

where do I add the Sort and \_Source??

Please help me on this...

Thank you.

---

<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 26, 2020, 3:26pm UTC](https://discuss.elastic.co/t/multiindex-query-with-sort-and-search-filters-different-for-each-indices/234948/2 "2020-06-26T15:26:37Z")

</div>

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