New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add initial update alias op to ES7 #2920
Conversation
* @param newIndexName index to point the alias to | ||
* @param timeout defaults to 1 minute | ||
*/ | ||
def swapIndexAlias( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can make this a little bit more broader.
What about renaming this to createAlias
and have a removePrevious: Boolean
and a isWriteIndex: Boolean
. I think it would allow more use cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, missed this comment, sorry @regadas. To make sure I understood you right:
createAlias
would just add a new index alias
removePrevious
would unlink a given alias from all indices
What does isWriteIndex
do?
I assume the Boolean would be derived from Try(AcknowledgedResponse)
by applying x.map(_.isAchnowledged).getOrElse(false)
Would be kinda great to still add a swap method since that's what we do when we create index from scratch every time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @6c697a61, ES alias can point to multiple indices and isWriteIndex
will tell that a given index is the one to write to when using the alias to write. (It wouldn't actually be a Boolean
in this case).
I think swapping can be achieved by using smth like createAlias(alias, index, removePrevious = true)
without having specific swap
op.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohh, have them as additional parameters! Got confused, sorry - thought you meant functions.
Adding removePrevious
, but still not clear of how isWriteIndex
is intended to be used. I understand what it is, just want to make sure we are on the same page about how it should be used. Do you mean we could put it as an additional parameter in ensureIndex to be able to prevent writing to an aliasedIndex @regadas?
Codecov Report
@@ Coverage Diff @@
## master #2920 +/- ##
==========================================
- Coverage 72.66% 70.03% -2.64%
==========================================
Files 224 224
Lines 7452 7452
Branches 312 330 +18
==========================================
- Hits 5415 5219 -196
- Misses 2037 2233 +196
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @6c697a61 sorry for the late reply. Left a few comments and do you think we can extend this to the other ES versions?
timeout: TimeValue | ||
): AcknowledgedResponse = { | ||
|
||
val getAliasesResponse = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be moves after L#208
val request = new IndicesAliasesRequest() | ||
.addAliasAction( | ||
new AliasActions(AliasActions.Type.ADD) | ||
.index(indexName) | ||
.alias(alias) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I meant with isWriteIndex: Boolean
was smth along the lines of:
val request = new IndicesAliasesRequest() | |
.addAliasAction( | |
new AliasActions(AliasActions.Type.ADD) | |
.index(indexName) | |
.alias(alias) | |
) | |
// indices: Iterable[(String, Boolean)] (index name, is write index) | |
require( | |
indices.find(_._2).size == 1, | |
"Only one index per alias can be assigned to be the write index at a time" | |
val request = indices.foldLeft(new IndicesAliasesRequest()) { | |
case (request, (idx, isWriteIndex)) => | |
request.addAliasAction( | |
new AliasActions(AliasActions.Type.ADD) | |
.index(idx) | |
.writeIndex(isWriteIndex) | |
.alias(alias) | |
) | |
} |
* @param timeout defaults to 1 minute | ||
*/ | ||
def createOrUpdateAlias( | ||
nodes: Iterable[HttpHost], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer if we just have methods with ElasticsearchOptions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think ES 5 will be the only version that doesn't have the same ES alias behaviour.
This has been ongoing for a while? What needs to be done to get it merged? |
Co-authored-by: Liza Meleshchuk <elizavetam@spotify.com>
Hi @clairemcginty and @regadas, can we add a few methods here?
Related to #3132