You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by js...@apache.org on 2025/03/20 15:41:02 UTC
(unomi) branch draft-index-template updated: draft: use index-template for rollover indices
This is an automated email from the ASF dual-hosted git repository.
jsinovassinnaik pushed a commit to branch draft-index-template
in repository https://gitbox.apache.org/repos/asf/unomi.git
The following commit(s) were added to refs/heads/draft-index-template by this push:
new f54ed092b draft: use index-template for rollover indices
f54ed092b is described below
commit f54ed092bc5005918382db82561f1ec567f8c1e8
Author: jsinovassin <js...@jahia.com>
AuthorDate: Thu Mar 20 16:40:52 2025 +0100
draft: use index-template for rollover indices
---
...-2.2.0-10-rolloverAndMigrateEventSession.groovy | 22 +++++++++++++++-
.../2.2.0/create_index_template_query.json | 30 ++++++++++++++++++++++
.../2.2.0/create_rollover_policy_query.json | 2 +-
3 files changed, 52 insertions(+), 2 deletions(-)
diff --git a/tools/shell-commands/src/main/resources/META-INF/cxs/migration/migrate-2.2.0-10-rolloverAndMigrateEventSession.groovy b/tools/shell-commands/src/main/resources/META-INF/cxs/migration/migrate-2.2.0-10-rolloverAndMigrateEventSession.groovy
index 7da6f86c3..185702a98 100644
--- a/tools/shell-commands/src/main/resources/META-INF/cxs/migration/migrate-2.2.0-10-rolloverAndMigrateEventSession.groovy
+++ b/tools/shell-commands/src/main/resources/META-INF/cxs/migration/migrate-2.2.0-10-rolloverAndMigrateEventSession.groovy
@@ -41,6 +41,26 @@ context.performMigrationStep("2.2.0-create-rollover-policy", () -> {
HttpUtils.executePutRequest(context.getHttpClient(), esAddress + "/_ilm/policy/" + rolloverPolicyName, rolloverQueryBody, null)
})
+
+context.performMigrationStep("2.2.0-create-index-template-event", () -> {
+ String baseRequest = MigrationUtils.resourceAsString(bundleContext, "requestBody/2.2.0/create_index_template_query.json")
+ String mapping = MigrationUtils.extractMappingFromBundles(bundleContext, "event.json")
+
+ String indexTemplateQueryBody = MigrationUtils.buildIndexCreationRequestWithRollover(baseRequest, mapping, context, rolloverPolicyName, rolloverEventAlias)
+ indexTemplateQueryBody = indexTemplateQueryBody.replace("#indexPattern", indexPrefix + "-event-00*")
+ HttpUtils.executePutRequest(context.getHttpClient(), esAddress + "/_index_template/" + indexPrefix + "-event-template", indexTemplateQueryBody, null)
+})
+
+
+context.performMigrationStep("2.2.0-create-index-template-session", () -> {
+ String baseRequest = MigrationUtils.resourceAsString(bundleContext, "requestBody/2.2.0/create_index_template_query.json")
+ String mapping = MigrationUtils.extractMappingFromBundles(bundleContext, "session.json")
+
+ String indexTemplateQueryBody = MigrationUtils.buildIndexCreationRequestWithRollover(baseRequest, mapping, context, rolloverPolicyName, rolloverSessionAlias)
+ indexTemplateQueryBody = indexTemplateQueryBody.replace("#indexPattern", indexPrefix + "-session-00*")
+ HttpUtils.executePutRequest(context.getHttpClient(), esAddress + "/_index_template/" + indexPrefix + "-session-template", indexTemplateQueryBody, null)
+})
+
context.performMigrationStep("2.2.0-create-event-index", () -> {
if (!MigrationUtils.indexExists(context.getHttpClient(), esAddress, newEventIndex)) {
String baseRequest = MigrationUtils.resourceAsString(bundleContext, "requestBody/2.2.0/base_index_withRollover_request.json")
@@ -48,7 +68,7 @@ context.performMigrationStep("2.2.0-create-event-index", () -> {
String configureAliasBody = MigrationUtils.resourceAsString(bundleContext, "requestBody/2.2.0/configure_alias_body.json")
String newIndexSettings = MigrationUtils.buildIndexCreationRequestWithRollover(baseRequest, mapping, context, rolloverPolicyName, rolloverEventAlias)
- HttpUtils.executePutRequest(context.getHttpClient(), esAddress + "/" + newEventIndex, newIndexSettings, null)
+ HttpUtils.executePutRequest(context.getHttpClient(), esAddress + "/" + newEventIndex, null, null)
MigrationUtils.configureAlias(context.getHttpClient(), esAddress, rolloverEventAlias, newEventIndex, Collections.emptySet(), configureAliasBody, context)
}
})
diff --git a/tools/shell-commands/src/main/resources/requestBody/2.2.0/create_index_template_query.json b/tools/shell-commands/src/main/resources/requestBody/2.2.0/create_index_template_query.json
new file mode 100644
index 000000000..a144085b1
--- /dev/null
+++ b/tools/shell-commands/src/main/resources/requestBody/2.2.0/create_index_template_query.json
@@ -0,0 +1,30 @@
+{
+ "index_patterns": [
+ "#indexPattern"
+ ],
+ "template": {
+ "settings": {
+ "index.lifecycle.name": "#lifecycleName",
+ "index.lifecycle.rollover_alias": "#lifecycleRolloverAlias",
+ "index.number_of_shards": #numberOfShards,
+ "index.number_of_replicas": #numberOfReplicas,
+ "index.mapping.total_fields.limit": #mappingTotalFieldsLimit,
+ "index.max_docvalue_fields_search": #maxDocValueFieldsSearch,
+ "analysis": {
+ "analyzer": {
+ "folding": {
+ "type": "custom",
+ "tokenizer": "keyword",
+ "filter": [
+ "lowercase",
+ "asciifolding"
+ ]
+ }
+ }
+ }
+ },
+ "mappings": #mappings
+ }
+ },
+ "priority": 100
+}
diff --git a/tools/shell-commands/src/main/resources/requestBody/2.2.0/create_rollover_policy_query.json b/tools/shell-commands/src/main/resources/requestBody/2.2.0/create_rollover_policy_query.json
index 2084db3e7..5728efa73 100644
--- a/tools/shell-commands/src/main/resources/requestBody/2.2.0/create_rollover_policy_query.json
+++ b/tools/shell-commands/src/main/resources/requestBody/2.2.0/create_rollover_policy_query.json
@@ -10,4 +10,4 @@
}
}
}
-}
\ No newline at end of file
+}