Search code examples
elasticsearchelastic-rest-client

Elastic rest high level api RolloverRequest


I am trying to use RolloverRequest to automatically rollover a time based index.

My index format is log-000001, log-000002 etc. and alias is log

If i'm using REST API, then I do not have to supply the new index name as rollover happens automatically. But I do not see a way of getting the same using high level rest api

RolloverRequest request = new RolloverRequest(aliasName, newIndexname);

Even though documentation says that newIndexName is optional, there is no constructor which takes only one param, there is no default constructor either.

My question is, is there a way to pass just alias name to RolloverRequest for automatic rollover? If not, is there something like that planned or is the documentation misleading?


Solution

  • I got it solved. What was missing was an index template. A rollover will not copy the existing mapping from the index -- so it is lost that way. If you create an index template which matches the alias, then new index will also have the same mapping as that of old rolled over index