Elasticsearch - Missing Indexing on Alias ​​Update

In this blog post: https://www.elastic.co/blog/changing-mapping-with-zero-downtime/ , I use the recommended best practice to update the index in production with zero downtime using aliases. Regardless, we occasionally see "index missing" exceptions in our application during upgrade. I can't show you how to diagnose this and I'm not sure what the problem is.

Current process

  • Determine that the index targets the default alias (there is at most 1)
  • The sequence of the current index name, adding / increasing counter: index-name-v1
  • Create new index and fill data
  • Update the alias in one operation: drop the old index and add a new index
  • Remove an index that is version -2 from the current current index - This is to ensure that an index returning data before the alias was updated is not deleted.

Despite all this, we get a random and regular index that skips errors when querying data. The alias is never deleted, only updated atomically. Is there something wrong with this approach that I am not considering?

public virtual void SwapAlias(string aliasName, string oldIndexName, string newIndexName)
    Client.Alias(a =>
        a.Add(add => add.Alias(aliasName).Index(newIndexName));

        if (oldIndexName != null && oldIndexName != newIndexName)
            a.Remove(remove => remove.Alias(aliasName).Index(oldIndexName));

        return a;



source to share

All Articles