# Search multiple indexes with filter

**URL:** <https://discuss.elastic.co/t/search-multiple-indexes-with-filter/97930>\
**Category:** Elasticsearch\
**Created:** [August 22, 2017, 2:47pm UTC](https://discuss.elastic.co/t/search-multiple-indexes-with-filter/97930 "2017-08-22T14:47:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Pocivalnik](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/david_pocivalnik/32/56098_2.png) [@David\_Pocivalnik](https://discuss.elastic.co/u/David_Pocivalnik)\
**Post date:** [August 22, 2017, 2:47pm UTC](https://discuss.elastic.co/t/search-multiple-indexes-with-filter/97930/1 "2017-08-22T14:47:43Z")

</div>

Version of ES currently in use: 5.2

I'm trying to create a query, including filters, that runs against two indexes.

Are there any preconditions , e.g. common fields, some kind of link between documents of a different index, in order to get this kind of query done ?

For instance, I have two indexes:

- 'files' - containing indexed files
- 'meta' - containing some meta data of a "client/user"

for each document within 'meta' there can be 0..n document within 'files'.  
Because of this definition, the ID's do not match. Exemplary, an ID of a meta-document is: '01-1212-0', an ID of a file "belonging" to the mentioned meta-document is: '01-1212-0+1'.

The aim is to create a query that matches e.g. a 'username' within 'meta'-Index, and the query\_string query is additionally looking for e.g. "bytes"

the following query (no special query\_string, just match\_all) gets me some results

```
{
"size" : 10,
"query" : {
"bool" : {
  "must" : [{
      "match_all" : {
        "boost" : 1.0
      }}],
  "filter" : [{
      "bool" : {
        "should" : [{
            "term" : {
              "username" : {
                "value" : "hugo"
              }}}]}}]}}}

```

but when I replace match\_all with the following

```
"query_string" : {
        "query" : "bytes" }

```

I get no results.

Any ideas on what I can do to make this happen?

Thanks in advance

---

<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:** [September 19, 2017, 2:47pm UTC](https://discuss.elastic.co/t/search-multiple-indexes-with-filter/97930/2 "2017-09-19T14:47:50Z")

</div>

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