Add new is_write_index
flag to Alias MetaData
#30195
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
in response to #30061.
This PR rebuilds aliasAndIndexLookup every time it wants to use it for alias validation. Depends on outcome of #29575 for using a pre-built data-structure.
This PR introduces a concept in aliases called
is_write_index
. Whentrue
on a specificalias definition associated with an
index
, index requests using the associated alias name willresolve to this
index
for indexing.Write now, if one attempts to index a document using an alias that points to multiple indices, there is no way to resolve which one, so an exception is thrown. With this flag, you can have an alias that points to a specific index in a set of indices as the one to write to.
It is possible to set an index as an alias' write-index during index creation:
Now, index requests like
PUT bar/_doc/_id
will route to indexfoo1
. Another index,foo2
, isfree to also have an alias named "bar" pointing to it. This alias needs to be configured with
is_write_index
set tofalse
.is_write_index
is defaulted tofalse
if not specified, or it can be explicitly set tofalse
.Now, searches against
bar
will point to both indices, but index requests will be routed tofoo1
.These settings can be updated in the
_aliases
API like so:How does this relate to Rollover? Rollover depended on rollover-aliases that only point to
one index since multiple would break indexing. Now that the same alias can point to multiple indices, the only requirement we have is that there is only one write index.
Here is an example scenario that didn't work before, but works with these changes: