0

For instance, I want to rollover my index only when both index_age:"1h" AND doc_count:1

{
"policy": {
    "description": "Example rollover policy.",
    "default_state": "rollover",
    "states": [
        {
            "name": "rollover",
            "actions": [
                {
                    "rollover": {
                        "min_index_age": "1h",
                        "min_doc_count": 1
                    }
                }
            ],
            "transitions": []
        }
    ],
    "ism_template": {
        "index_patterns": [
            "log*"
        ],
        "priority": 100
    }
}

Doing at GET /_opendistro/_ism/explain/log-000001?pretty gave (excluded few fields):

{
"info": {
  "message": "Successfully rolled over index [index=log-000001]",
  "conditions": {
    "min_index_age": {
      "condition": "1h",
      "current": "1.1h",
      "creationDate": 1685093175627
    },
    "min_doc_count": {
      "condition": 1,
      "current": 0
    }
  }
}

Even though the 2nd condition was not met, still the rollover happened.

1 Answers1

1

OPENSEARCH

Currently, there are only min conditions, and whenever one of the conditions is satisfied it will trigger the rollover.

Rollover Official documentation

Rolls an alias over to a new index when the managed index meets one of the rollover conditions.

ELASTICSEARCH

Rollover official documentation

There are max and min conditions available for Elasticsearch. You can use multiple max and min conditions.

The index will rollover if any max_* condition is satisfied and all min_* conditions are satisfied.

An example:

The following request only rolls over the index if the current write index meets one or more of the following conditions:

  • The index was created 7 or more days ago.
  • The index contains 1,000 or more documents.
  • The index’s largest primary shard is 50GB or larger.

POST my-data-stream/_rollover
{
  "conditions": {
    "max_age": "7d",
    "max_docs": 1000,
    "max_primary_shard_size": "50gb",
    "max_primary_shard_docs": "2000"
  }
}

NOTE: max conditions released on Elasticsearch version 8.4 and 7.17.6, it's available for the versions I mentioned and above.

Musab Dogan
  • 1,811
  • 1
  • 6
  • 8
  • 1
    I believe you have a typo in this answer. You wrote: **You can use multiple max conditions, which must be satisfied before rollover.** But then you quoted something that says the opposite: **The index will rollover if _any_ `max_` condition is satisfied and _all_ `min_` conditions are satisfied.** – Mageician Jun 16 '23 at 15:30
  • Thanks for your comment @Mageician, you're right it can cause misunderstanding. I edited my answer. – Musab Dogan Jun 16 '23 at 22:31