Tom
Tom

Reputation: 6342

I have to manually run rollover for the new documents to go to the new index

I am using ES7.10.2,and I have following simple snippet to demontrate the usage of rollover api.

But I find that I have to run logs-write/_rollover manually to make the rollover work. I would ask how to automatic rollover.

PUT _template/logs
{
  "template": "logs-*",
  "settings": {
    "number_of_shards": 5,
    "number_of_replicas": 1
  },
  "aliases": {
    "logs-search": {}
  }
}

PUT logs-000001
{
  "aliases": {
    "logs-write": {
      "rollover": {
        "conditions": {
          "max_age": "60s",
          "max_docs": 2
        }
      }
    }
  }
}



POST logs-write/_doc/1
{
  "user": "kimchy",
  "post_date": "2009-11-15T14:12:12",
  "message": "trying out Elasticsearch"
}



POST logs-write/_doc/2
{
  "user": "kimchy2",
  "post_date": "2009-11-15T14:12:12",
  "message": "trying out Elasticsearch1"
}

POST logs-write/_doc/3
{
  "user": "kimchy3",
  "post_date": "2009-11-15T14:12:12",
  "message": "trying out Elasticsearch1"
}

#Before I run the logs-write/_rollover logs-000002 index doesn't exist,which means auto rollover doesn't work
POST logs-write/_rollover
{
  "conditions": {
    "max_age": "5s",
    "max_docs": 2,
    "max_size": "5mb"
  }
}

#id 4 document goes to the logs-000002 index, which means that rollover has taken effect
POST logs-write/_doc/4
{
  "user": "kimchy4",
  "post_date": "2009-11-15T14:12:12",
  "message": "trying out Elasticsearch1"
}

Upvotes: 1

Views: 1104

Answers (1)

Val
Val

Reputation: 217334

The rollover process is run every 10 minutes by default, so you need to make sure to let it the chance to run.

You can change the indices.lifecycle.poll_interval to a lower value setting if you want to test it out.

Upvotes: 1

Related Questions