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.
OPENSEARCH
Currently, there are only
minconditions, and whenever one of the conditions is satisfied it will trigger the rollover.Rollover Official documentation
ELASTICSEARCH
Rollover official documentation
There are
maxandminconditions available for Elasticsearch. You can use multiple max and min conditions.An example:
The following request only rolls over the index if the current write index meets one or more of the following conditions:
NOTE: max conditions released on Elasticsearch version 8.4 and 7.17.6, it's available for the versions I mentioned and above.