1

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?

senseiwu
  • 5,001
  • 5
  • 26
  • 47

2 Answers2

1

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

senseiwu
  • 5,001
  • 5
  • 26
  • 47
0

According to below link

https://www.elastic.co/guide/en/elasticsearch/client/java-rest/6.7/java-rest-high-rollover-index.html

The alias (first argument) that points to the index to rollover, and the name of the new index in case the rollover operation is performed. The new index argument is optional, and can be set to null

So you can use RolloverRequest as follows:

RolloverRequest request = new RolloverRequest("alias", null);
Anas Mehar
  • 2,739
  • 14
  • 25
chengc
  • 1