elastic / elasticsearch

Free and Open Source, Distributed, RESTful Search Engine
https://www.elastic.co/products/elasticsearch
Other
69.55k stars 24.61k forks source link

Support parsing templated variables in the alias filter section of index_templates #103230

Open kevinw0123 opened 9 months ago

kevinw0123 commented 9 months ago

Description

I'm trying to set up an index template, which creates an alias with a filter clause based on the date provided in the index's name.

I'd like the index_template API to support a template like this:

PUT /_template/example-template
{
    "index_patterns": [
        "example-index-*"
    ],
    "settings": {
        "number_of_shards": 1,
        "index": {
            "lifecycle": {
                "name": "example-policy",
                "parse_origination_date": true,
                "rollover_alias": "example-alias-1"
            }
        }
    },
    "mappings": {
        "_source": {
            "enabled": true
        },
        "properties": {
            "timestamp": {
                "type": "date"
            }
        }
    },
    "aliases": {
        "example-alias-1": {
            "filter": {
                "range": {
                    "timestamp": {
                        "gte": "{{index.settings.lifecycle.origination_date}}/d",
                        "lt": "{{index.settings.lifecycle.origination_date}}d/-1d"
                    }
                }
            }
        }
    }
}
elasticsearchmachine commented 9 months ago

Pinging @elastic/es-data-management (Team:Data Management)