ElasticSearch doesn't support date math for alias when create index template yet?

It seems that date math support index alias names in 7.13, but using date math when creating index template is still wrong, here is the curl cmd and result I get when create template with date math alias

#cmd
curl -XPUT "localhost:9200/_template/test?pretty" -H "Content-Type:application/json" -d '{
    "index_patterns": [
        "test-*"
    ],
    "order": 0,
    "aliases": {
        "<test-{now/h}>": {}
    }
}'
# result
{
    "error": {
        "root_cause": [
            {
                "type": "invalid_alias_name_exception",
                "reason": "Invalid alias name [<test-{now/h}>]: must not contain the following characters [ , \", *, \\, <, |, ,, >, /, ?]"
            }
        ],
        "type": "invalid_alias_name_exception",
        "reason": "Invalid alias name [<test-{now/h}>]: must not contain the following characters [ , \", *, \\, <, |, ,, >, /, ?]"
    },
    "status": 400
}

Are you using version 7.13 or newer? See Date math support for aliases by Tommmster · Pull Request #67226 · elastic/elasticsearch · GitHub

Hi spinscale,
I'm using 7.13.4 docker for my test. I've seen the pr, and you mean it already supports date math expression when create template? from this commit it seems that already support, why my test in 7.13.4 got an error?

I opened an issue at Date Math Support for Aliases does not work in Index Templates · Issue #75651 · elastic/elasticsearch · GitHub

1 Like