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:
{
"recent": {
"filter": {
"range": {
"@timestamp": {
"gte": "now-3d/d"
}
}
}
}
}
It seems to work correctly but I cannot remove the index from the alias afterwards using:
POST _aliases
{
"actions": [
{
"remove": {
"index": ".ds-test-2025.05.11-000001",
"alias": "recent"
}
}
]
}
with the following error:
{
"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:
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!