# Alias with multiple filters

**URL:** <https://discuss.elastic.co/t/alias-with-multiple-filters/243095>\
**Category:** Elasticsearch\
**Created:** [July 29, 2020, 4:30pm UTC](https://discuss.elastic.co/t/alias-with-multiple-filters/243095 "2020-07-29T16:30:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rom1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rom1/32/49699_2.png) [@Rom1](https://discuss.elastic.co/u/Rom1)\
**Post date:** [July 29, 2020, 4:30pm UTC](https://discuss.elastic.co/t/alias-with-multiple-filters/243095/1 "2020-07-29T16:30:18Z")

</div>

Hi guys,

In order to filter data to be displayed in a drop down list of the control visualization in Kibana, I decided to create an alias on my index by filtering some data but I'm facing like an issue.  
Here is the part of the template

```auto
...
"aliases": {
   "filtered-data" : {
      "bool": {
         "filter": [
            { "term" : { "Type" : "Missing data" } },
            { "term" : { "Level" : "Detail" } }
         ]
      }
   }
},
...

```

But when I get the corresponding template, the alias contains one filter only, not both.  
It works fine if I have just one filter

1. Does alias accept multiple filters?
2. Is this an issue to be reported?
3. Is there any workaround regarding my need?

Thank you in advance

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [August 3, 2020, 10:58am UTC](https://discuss.elastic.co/t/alias-with-multiple-filters/243095/2 "2020-08-03T10:58:20Z")

</div>

can you create a reproducible example, please? This would help a lot to fully follow the steps that you took.

Thank you!

---

<div class="post-metadata">

**Author:** ![Rom1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rom1/32/49699_2.png) [@Rom1](https://discuss.elastic.co/u/Rom1)\
**Post date:** [August 5, 2020, 9:49am UTC](https://discuss.elastic.co/t/alias-with-multiple-filters/243095/3 "2020-08-05T09:49:55Z")

</div>

For sure,

If I create this new template:

```auto
PUT _template/mytemplate
{
   "index_patterns": ["myindex"],
   "aliases": {
      "filtered-data" : {
         "bool": {
            "filter": [
               { "term" : { "Type" : "Missing data" } },
               { "term" : { "Level" : "Detail" } }
            ]
         }
      }
   }
}

```

The template is created:

```auto
GET _cat/templates/mytemplate?v
name index_patterns order version
mytemplate [myindex] 0     

```

And when I check its content, you can see that the alias has not been created correctly.  
There is just one term filtered.

```auto
GET _template/mytemplate
{
  "mytemplate" : {
    "order" : 0,
    "index_patterns" : ["myindex"],
    "settings" : { },
    "mappings" : { },
    "aliases" : {
      "filtered-data" : {
        "filter" : {
          "term" : {
            "Level" : "Detail"
          }
        }
      }
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [August 12, 2020, 8:37am UTC](https://discuss.elastic.co/t/alias-with-multiple-filters/243095/4 "2020-08-12T08:37:39Z")

</div>

I think your JSON structure is wrong. Try this

```auto
PUT _template/mytemplate
{
  "index_patterns": [
    "myindex"
  ],
  "aliases": {
    "filtered-data": {
      "filter": {
        "bool": {
            "filter": [
               { "term" : { "Type" : "Missing data" } },
               { "term" : { "Level" : "Detail" } }
            ]
         }
      }
    }
  }
}

```

However, you should get a proper exception instead of a wrongly setup alias in your case. I'll open an issue for that.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [August 12, 2020, 8:45am UTC](https://discuss.elastic.co/t/alias-with-multiple-filters/243095/5 "2020-08-12T08:45:29Z")

</div>

I opened [https://github.com/elastic/elasticsearch/issues/61009](https://github.com/elastic/elasticsearch/issues/61009) if you want to follow

---

<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 9, 2020, 8:45am UTC](https://discuss.elastic.co/t/alias-with-multiple-filters/243095/6 "2020-09-09T08:45:47Z")

</div>

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