Index Date Math with seconds

Hi All,

When I try to create an index using date math expression

PUT /%3Cdata-index-%7Bnow%2Fm%7Byyyy-MM-dd-HH-mm-ss%7D%7D%3E

which produces an index as data-index-2021-06-16-12-41-00

Why seconds are always 00 (if you execute the same command multiple times)?

I think that seconds were supported:

https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html

How can I add seconds to the expression?

Thank you in advance

You are only asking it to resolve to the minute, ie: ...{now/m{yyyy... - to resolve down to the seconds, you need to change your expression to to be ...{now/s{yyyy...:

PUT /%3Cdata-index-%7Bnow%2Fs%7Byyyy-MM-dd-HH-mm-ss%7D%7D%3E
1 Like

Why are you using seconds in an index name?

1 Like

Thank you! I did not notice the precision parameter!

I was trying to use it as a naming pattern in my ILM's bootsrapping but I noticed other issues later when the lifecycle policy was trying to rollover the newly created bootstrapped index, with all date math options I tried. Seconds to days (I wanted to have a human readable rolled over index naming convention instead of -000001):

Index lifecycle error
number_format_exception: For input string: "ss}}"

Index lifecycle error
number_format_exception: For input string: "mm}}"

Index lifecycle error
number_format_exception: For input string: "dd}}"

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.