Gives the expected restored-<index_name>-index, because it matches the first character and then the rest of the characters.
I don’t know why it would do that. But the behaviour is consistent. One variable in the replacement: duplicated text. Two ore more variables: works as expected.
Looks like we’re still using 2.19 on AWS. I believe we updated as far as we could about a year ago, when the big EOL wave was coming for various hosted versions.
It looks like there’s 3.x versions available now. Is this something that’s fixed in 3.x, then?
@StuartBertramTXP As you’ve already noticed, the observed incorrect restored index name is caused by the rename_pattern.
When you use * in the pattern, it matches 0 or more characters. Because .* can also match an empty string, the replacement is applied twice:
security-auditlog-2026.08.19
an empty string at the end of the index name
This will result in restored-security-auditlog-2026.08.19-indexrestored--index.
Instead, use + in rename_pattern. + means 1 or more characters, so it won’t match an empty string.
@pablo Thanks for the explanation. I guess that makes some sense. But I’ve somehow managed to miss that behaviour of replacement in 20+ years of programming!
.* is a greedy operator, so I expect it to match any string of any length. Which is the full string. And then it’s done. It matched its input. Nothing else to do. But I’ve just checked in two different languages and they both show the same behaviour of matching the empty string at the end. Interestingly, sed does not and behaves as I originally expected (presumably because it’s a stream editor and so the context is slightly different)
At least we’ve got this three and a half year old oddity cleared up!