Add support for specifying reindexing script for system index migration#119001
Add support for specifying reindexing script for system index migration#119001alexey-ivanov-es merged 12 commits intoelastic:mainfrom
Conversation
Adds support for setting a reindexing script for system index migration during /_migration/system_features task. Script is set using SystemIndexDescriptor.Builder.setMigrationScript method
| */ | ||
| private static final String LEGACY_VERSION_FIELD_VALUE = "8.12.0"; | ||
|
|
||
| private static final String REINDEX_SCRIPT_FROM_V7 = """ |
There was a problem hiding this comment.
This change here is only to illustrate approach. I'll revert it later and create a separate PR for 8.x branch after all other changes is backported there. The script will only be in 8.18, not in 9.0
|
Verified manually 7.0.1 (-> 7.17.0) -> 8.18:
|
|
Hi @alexey-ivanov-es, I've created a changelog YAML for you. |
|
Pinging @elastic/es-core-infra (Team:Core/Infra) |
JVerwolf
left a comment
There was a problem hiding this comment.
LGTM. There is some unused code to clean up, and I left a comment on the Javadoc, but overall this looks good.
I was thinking that this reindexing script is tied to the migration between specific versions, in this case V7->V8. I wonder if we should make that relationship explicit somehow? Otherwise, during the next migration from V8->V9, any descriptor with a script will likely be broken by default.
| /** | ||
| * Script to modify the documents in index created | ||
| * before {@link TransportGetFeatureUpgradeStatusAction#NO_UPGRADE_REQUIRED_INDEX_VERSION}. | ||
| * Can be null. | ||
| */ |
There was a problem hiding this comment.
WDYT of adding some additional details here?
e.g.:
/**
* An optional reindexing script to use when migrating an index from V7->V8. This script can be used to modify documents
* before they are added to the new index. For example, it could be used to migrate off deprecated features.
* <p>
* See https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html#reindex-scripts
*/
There was a problem hiding this comment.
ok, I'll add more details here, however, I would try to avoid mentioning any specific versions 🙂 Thank you!
| import org.apache.lucene.util.automaton.CharacterRunAutomaton; | ||
| import org.apache.lucene.util.automaton.Operations; | ||
| import org.apache.lucene.util.automaton.RegExp; | ||
| import org.elasticsearch.action.admin.cluster.migration.TransportGetFeatureUpgradeStatusAction; |
There was a problem hiding this comment.
In JavaDoc, line 151. I think it is ok
| public Builder setMigrationScript(String migrationScript) { | ||
| this.migrationScript = migrationScript; | ||
| return this; | ||
| } | ||
|
|
There was a problem hiding this comment.
Should we call this setV7toV8MigrationScript? This way, we can deprecate it with a annotation later, and easily track usages of outdated scripts prior to the next migration. For the next migration, we'd then add setV8toV9MigrationScript, and so on.
There was a problem hiding this comment.
I don't really want to mention any specific versions in the name of the method, because otherwise we will have to do additional job for every major release and I think it is better to avoid it. Also #119001 (comment)
@JVerwolf it is. I thought about having some kind of Map<Version, Script>, but it would complicate things unnecessarily: the reindexing script is only required in the last (two) minor of previous major (in our case in 8.18 and 8.19 for migration to 9.0). Therefore, the script should only exist in those minors and be introduced in the "last minor" branch after it diverges from the "next major" ( |
💔 Backport failed
You can use sqren/backport to manually backport by running |
|
8.x PR: #120333 |
Adds support for setting a reindexing script for system index migration during
/_migration/system_featurestask.Script is set using
SystemIndexDescriptor.Builder.setMigrationScriptmethod.Changes in this PR will be backported to 8.x branch