Using elasticsearch 8.4.3 with Java 17 and a cluster of 3 nodes where 3 are master eligible, we start with following situation:
- index products-2023-01-12-0900 which has an alias current-products
We then start a job that creates a new index products-2023-01-12-1520 and at the end using elastic-rest-client on client side and alias API, we make this call:
At 2023-01-12 16:27:26,893:
POST /_aliases
{"actions":[
{
"remove": {
"alias":"current-products",
"index":"products-*"
}
},
{
"add":{
"alias":"current-products",
"index":"products-2023-01-12-1520"}
}
]}
And we get the following response 26 millis after with HTTP response code 200:
{"acknowledged":true}
But looking at what we end up with, we still have old index with current-products alias.
I don't understand why it happens, and it does not happen 100% of the time (it happened 2 times out of around 10 indexations). Is it a known bug ? or a regular behaviour ?
Edit for @warkolm:
GET /_cat/aliases?v before indexation as of now:
alias index filter routing.index routing.search is_write_index
current-products products-2023-01-13-1510 - - - -
_cat/aliases?v
showing this? – Servilerollover_alias
to automatize the rollover move alias process? elastic.co/guide/en/elasticsearch/reference/current/… You can even use datastream indices for your case, and it would be better. elastic.co/guide/en/elasticsearch/reference/current/… – SnubnosedPOST _aliases
API not returning{"acknowledged":true}
every time you run. Do you have any check and retry mechanism until get{"acknowledged":true}
? Are you sure the API successfully runs every time you push? – Snubnosed