-
Notifications
You must be signed in to change notification settings - Fork 113
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
Alias index transform #1049
Open
n-dohrmann
wants to merge
25
commits into
opensearch-project:main
Choose a base branch
from
n-dohrmann:alias_index_transform
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Alias index transform #1049
Changes from 8 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
e5631ac
adding write index check for alias of target index
n-dohrmann 7fbde10
trying out putMapping changes
n-dohrmann e0274ec
linting previous change
n-dohrmann f866378
variable target index PR ready for discussion...
n-dohrmann 4abb60f
Merge branch 'main' into alias_index_transform
n-dohrmann e687f5f
linting previous commit
n-dohrmann f70faab
Merge branch 'alias_index_transform' of github.com:n-dohrmann/index-m…
n-dohrmann a3586f5
reduce throw count to < 2 in createTargetIndex
n-dohrmann 024696c
adding write index check for alias of target index
n-dohrmann 3e43d36
trying out putMapping changes
n-dohrmann 123378b
linting previous change
n-dohrmann ef70a74
variable target index PR ready for discussion...
n-dohrmann 3be1246
linting previous commit
n-dohrmann 4138ff0
reduce throw count to < 2 in createTargetIndex
n-dohrmann 7db746d
Merge branch 'alias_index_transform' of github.com:n-dohrmann/index-m…
n-dohrmann 01bd3a2
changing alias checker control flow
n-dohrmann ab17632
adding test case for aliased transform target index
n-dohrmann 448161b
quick commit before changing branches
n-dohrmann 0b02a23
Merge branch 'main' into alias_index_transform
n-dohrmann e50468b
adding code for quick question
n-dohrmann 7dd3530
adding to target alias transform test
n-dohrmann ce65e6c
Merge branch 'main' into alias_index_transform
n-dohrmann a738944
adding explicit variable for sourceIndex
n-dohrmann 0bb9ce8
adding unchecked cast suppressor to test method
n-dohrmann 7cf342a
Merge branch 'main' into alias_index_transform
bowenlan-amzn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
import org.opensearch.action.DocWriteRequest | ||
import org.opensearch.action.admin.indices.create.CreateIndexRequest | ||
import org.opensearch.action.admin.indices.create.CreateIndexResponse | ||
import org.opensearch.action.admin.indices.mapping.put.PutMappingRequest | ||
import org.opensearch.action.bulk.BackoffPolicy | ||
import org.opensearch.action.bulk.BulkItemResponse | ||
import org.opensearch.action.bulk.BulkRequest | ||
|
@@ -26,6 +27,7 @@ | |
import org.opensearch.indexmanagement.transform.util.TransformContext | ||
import org.opensearch.core.rest.RestStatus | ||
import org.opensearch.transport.RemoteTransportException | ||
import org.opensearch.action.support.master.AcknowledgedResponse | ||
|
||
@Suppress("ComplexMethod") | ||
class TransformIndexer( | ||
|
@@ -63,6 +65,20 @@ | |
throw TransformIndexException("Failed to create the target index") | ||
} | ||
} | ||
val writeIndexMetadata = clusterService.state().metadata.indicesLookup[targetIndex]!!.writeIndex | ||
if (clusterService.state().metadata.hasAlias(targetIndex)) { | ||
// return error if no write index with the alias | ||
if (writeIndexMetadata == null) { | ||
throw TransformIndexException("Target index alias has no write index") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. target_index [$targetIndex] is an alias but doesn't have write index |
||
} | ||
} | ||
val putMappingReq = PutMappingRequest(writeIndexMetadata?.index?.name).source(targetFieldMappings) | ||
val mapResp: AcknowledgedResponse = client.admin().indices().suspendUntil { | ||
putMapping(putMappingReq) | ||
} | ||
if (!mapResp.isAcknowledged) { | ||
logger.error("Target index mapping request failed") | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also move this inside to above if block? |
||
} | ||
|
||
@Suppress("ThrowsCount", "RethrowCaughtException") | ||
|
Oops, something went wrong.
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.
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.
This line should inside the below if block?