# Failed to create filtered alias with terms lookup

**URL:** <https://discuss.elastic.co/t/failed-to-create-filtered-alias-with-terms-lookup/225531>\
**Category:** Elasticsearch\
**Created:** [March 29, 2020, 5:39am UTC](https://discuss.elastic.co/t/failed-to-create-filtered-alias-with-terms-lookup/225531 "2020-03-29T05:39:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Junjun\_Zhang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/junjun_zhang/32/45613_2.png) [@Junjun\_Zhang](https://discuss.elastic.co/u/Junjun_Zhang)\
**Post date:** [March 29, 2020, 5:39am UTC](https://discuss.elastic.co/t/failed-to-create-filtered-alias-with-terms-lookup/225531/1 "2020-03-29T05:39:33Z")

</div>

Hello,

I have run into exactly the same problem reported in this closed topic: [Terms lookup in a filtered alias](https://discuss.elastic.co/t/terms-lookup-in-a-filtered-alias/206838). Since it's not been answered, I am posting it again.

Much appreciated in advance if someone could confirm this is unexpected behaviour, should be reported as a bug.

Best regards  
Junjun

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 29, 2020, 7:33am UTC](https://discuss.elastic.co/t/failed-to-create-filtered-alias-with-terms-lookup/225531/2 "2020-03-29T07:33:31Z")

</div>

Could you provide a full recreation script as described in [About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

---

<div class="post-metadata">

**Author:** ![Junjun\_Zhang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/junjun_zhang/32/45613_2.png) [@Junjun\_Zhang](https://discuss.elastic.co/u/Junjun_Zhang)\
**Post date:** [March 29, 2020, 4:42pm UTC](https://discuss.elastic.co/t/failed-to-create-filtered-alias-with-terms-lookup/225531/3 "2020-03-29T16:42:42Z")

</div>

Hi David,

Thanks for the quick response. Here are steps to reproduce the problem in Kibana (version 7.6.1):

```
PUT /colors/_doc/1
{
  "color": ["red", "green"]
}

PUT /colors/_doc/2
{
  "color": "blue"
}

PUT /products/_doc/1
{
  "id": "a",
  "color": "red"
}

PUT /products/_doc/2
{
  "id": "b",
  "color": "blue"
}

POST /_aliases
{
  "actions": [
    {
      "add": {
        "index": "products",
        "alias": "color2_products",
        "filter": {
          "terms": {
            "color": {
              "index": "colors",
              "id": "2",
              "path": "color"
            }
          }
        }
      }
    }
  ]
}

```

The last step of creating alias fails with the following response while same operation (with type added) works fine in version 5.6.9

```
{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "failed to parse filter for alias [color2_products]"
      }
    ],
    "type" : "illegal_argument_exception",
    "reason" : "failed to parse filter for alias [color2_products]",
    "caused_by" : {
      "type" : "illegal_state_exception",
      "reason" : "async actions are left after rewrite"
    }
  },
  "status" : 400
}

```

However, the following terms lookup query works as expected:

```
GET /products/_search
{
  "query": {
    "terms": {
        "color" : {
            "index" : "colors",
            "id" : "2",
            "path" : "color"
        }
    }
  }
}

```

Thanks,  
Junjun

---

<div class="post-metadata">

**Author:** ![Junjun\_Zhang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/junjun_zhang/32/45613_2.png) [@Junjun\_Zhang](https://discuss.elastic.co/u/Junjun_Zhang)\
**Post date:** [April 1, 2020, 1:16am UTC](https://discuss.elastic.co/t/failed-to-create-filtered-alias-with-terms-lookup/225531/4 "2020-04-01T01:16:02Z")

</div>

Just filed an issue on github: [https://github.com/elastic/elasticsearch/issues/54550](https://github.com/elastic/elasticsearch/issues/54550)

---

<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:** [April 29, 2020, 1:16am UTC](https://discuss.elastic.co/t/failed-to-create-filtered-alias-with-terms-lookup/225531/5 "2020-04-29T01:16:05Z")

</div>

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