Skip to content

Commit 3db24b6

Browse files
Script for migrating .watches and .triggered_watches indices (elastic#120371)
Introduces a script for reindexing .watches and .triggered_watches indices from V7, removing unused `types` field from documents if it exists.
1 parent 7252bc6 commit 3db24b6

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

docs/changelog/120371.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 120371
2+
summary: Script for migrating `.watches` and `.triggered_watches` indices
3+
area: "Watcher"
4+
type: upgrade
5+
issues: []

x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,13 @@ public class Watcher extends Plugin implements SystemIndexPlugin, ScriptPlugin,
285285
* to these old nodes that the mappings are newer than they are.
286286
*/
287287
private static final String LEGACY_VERSION_FIELD_VALUE = "8.12.0";
288+
289+
private static final String REINDEX_SCRIPT_FROM_V7 = """
290+
if (ctx._source.input?.search?.request?.types != null) {
291+
ctx._source.input.search.request.remove('types');
292+
}
293+
""";
294+
288295
private WatcherIndexingListener listener;
289296
private HttpClient httpClient;
290297
private BulkProcessor2 bulkProcessor;
@@ -808,6 +815,7 @@ public Collection<SystemIndexDescriptor> getSystemIndexDescriptors(Settings sett
808815
.setVersionMetaKey("version")
809816
.setOrigin(WATCHER_ORIGIN)
810817
.setIndexFormat(6)
818+
.setMigrationScript(REINDEX_SCRIPT_FROM_V7)
811819
.build(),
812820
SystemIndexDescriptor.builder()
813821
.setIndexPattern(TriggeredWatchStoreField.INDEX_NAME + "*")
@@ -818,6 +826,7 @@ public Collection<SystemIndexDescriptor> getSystemIndexDescriptors(Settings sett
818826
.setVersionMetaKey("version")
819827
.setOrigin(WATCHER_ORIGIN)
820828
.setIndexFormat(6)
829+
.setMigrationScript(REINDEX_SCRIPT_FROM_V7)
821830
.build()
822831
);
823832
}

0 commit comments

Comments
 (0)