Home > database >  Anyway to auto set refresh_interval for new index?
Anyway to auto set refresh_interval for new index?

Time:01-17

I know we can set refresh_interval for old indexes. But is there any way to set a new index too? My index change day by day ex: my-index-01.16.2023, my-index-01.17.2023... So I can't manually set it again every day. Any tips or solutions guys?

CodePudding user response:

You need to create an index template containing the refresh_interval setting for your new indexes:

PUT _index_template/my-index-template
{
  "index_patterns": ["my-index*"],
  "template": {
    "settings": {
      "refresh_interval": "1s"
    },
    "mappings": {
      "properties": {
        ...
      }
    },
    "aliases": {
      "my-index": { }
    }
  },
  "priority": 200,
  "composed_of": []
}
  • Related