# How to remove filter alias from backing index of a data stream?

**URL:** <https://discuss.elastic.co/t/how-to-remove-filter-alias-from-backing-index-of-a-data-stream/378011>\
**Category:** Elasticsearch\
**Created:** [May 11, 2025, 5:04am UTC](https://discuss.elastic.co/t/how-to-remove-filter-alias-from-backing-index-of-a-data-stream/378011 "2025-05-11T05:04:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aqiank](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aqiank/32/39723_2.png) [@aqiank](https://discuss.elastic.co/u/aqiank)\
**Post date:** [May 11, 2025, 5:04am UTC](https://discuss.elastic.co/t/how-to-remove-filter-alias-from-backing-index-of-a-data-stream/378011/1 "2025-05-11T05:04:19Z")

</div>

Hi, I have an alias in my index template for `test` data stream to let me query for data in the last few days like the following:

```auto
{
  "recent": {
    "filter": {
      "range": {
        "@timestamp": {
          "gte": "now-3d/d"
        }
      }
    }
  }
}

```

It seems to work correctly but I cannot remove the index from the alias afterwards using:

```auto
POST _aliases
{
  "actions": [
    {
      "remove": {
        "index": ".ds-test-2025.05.11-000001",
        "alias": "recent"
      }
    }
  ]
}

```

with the following error:

```auto
{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "The provided expressions [.ds-test-2025.05.11-000001] match a backing index belonging to data stream [test]. Data stream backing indices don't support aliases."
      }
    ],
    "type": "illegal_argument_exception",
    "reason": "The provided expressions [.ds-test-2025.05.11-000001] match a backing index belonging to data stream [test]. Data stream backing indices don't support aliases."
  },
  "status": 400
}

```

I can use the `recent` alias for search:

```auto
GET recent/_search
{
  "took": 2,
  "timed_out": false,
  "_shards": {
    "total": 1,
    "successful": 1,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": {
      "value": 1,
      "relation": "eq"
    },
    "max_score": 1,
    "hits": [
      {
        "_index": ".ds-test-2025.05.11-000001",
        "_id": "Yl2wvZYBm63werLaQdbq",
        "_score": 1,
        "_source": {
          "text": "Hello, World!",
          "@timestamp": "2025-05-11T00:00:00Z"
        }
      }
    ]
  }
}

```

so the backing index clearly supports alias but the error says to the contrary. The reason I want to do this is to remove old shards from being queried unnecessarily (e.g. thousands of shards) as the `recent` alias will be queried dozens of times per second. This is using Elasticsearch 8.18. What am I doing wrong? Thanks!

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [May 11, 2025, 1:37pm UTC](https://discuss.elastic.co/t/how-to-remove-filter-alias-from-backing-index-of-a-data-stream/378011/2 "2025-05-11T13:37:53Z")

</div>

> [@aqiank](#):
>
> so the backing index clearly supports alias but the error says to the contrary

The backing index has the alias because it was added during the creation by the index template, but as far as I know you cannot add or remove alias to backing indices.

> [@aqiank](#):
>
> The reason I want to do this is to remove old shards from being queried unnecessarily (e.g. thousands of shards) as the `recent` alias will be queried dozens of times per second.

I don't think this is necessary, Elasticsearch already has some improvements and know where the data is to query only the shards that have the data, some of these improvements are explained [here](https://www.elastic.co/blog/three-ways-improved-elasticsearch-scalability).

---

<div class="post-metadata">

**Author:** ![aqiank](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aqiank/32/39723_2.png) [@aqiank](https://discuss.elastic.co/u/aqiank)\
**Post date:** [May 11, 2025, 1:54pm UTC](https://discuss.elastic.co/t/how-to-remove-filter-alias-from-backing-index-of-a-data-stream/378011/3 "2025-05-11T13:54:00Z")

</div>

I see. Out of curiousity, is there a technical reason why it can't be removed or is it just not implemented?

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [May 11, 2025, 2:22pm UTC](https://discuss.elastic.co/t/how-to-remove-filter-alias-from-backing-index-of-a-data-stream/378011/4 "2025-05-11T14:22:10Z")

</div>

> [@aqiank](#):
>
> Out of curiousity, is there a technical reason why it can't be removed or is it just not implemented?

No Idea, I don't think the reason for this is documented anywhere.
