diff --git a/server/src/main/java/org/elasticsearch/Build.java b/server/src/main/java/org/elasticsearch/Build.java index c34a9737bf799..e6a149debe9b3 100644 --- a/server/src/main/java/org/elasticsearch/Build.java +++ b/server/src/main/java/org/elasticsearch/Build.java @@ -249,6 +249,14 @@ public String qualifiedVersion() { return version; } + /** + * Get the build version without any suffices like "-SNAPSHOT" or "-rc1". + * @return the build version with no suffix + */ + public String unqualifiedVersion() { + return version.replaceFirst("-.*", ""); + } + public boolean isProductionRelease() { return isSnapshot() == false && version.matches(".*(-alpha\\d+)|(-beta\\d+)|(-rc\\d+)") == false; } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/MlConfigIndex.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/MlConfigIndex.java index cf4ae29bf6aa7..13522221a88ee 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/MlConfigIndex.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/MlConfigIndex.java @@ -34,7 +34,7 @@ public static String indexName() { public static String mapping() { return TemplateUtils.loadTemplate( "/ml/config_index_mappings.json", - Build.current().version(), // Only needed for BWC with pre-8.10.0 nodes + Build.current().unqualifiedVersion(), // Only needed for BWC with pre-8.10.0 nodes MAPPINGS_VERSION_VARIABLE, Map.of("xpack.ml.managed.index.version", Integer.toString(CONFIG_INDEX_MAPPINGS_VERSION)) ); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/MlMetaIndex.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/MlMetaIndex.java index 4ece63acfa27f..78bc396ac31ca 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/MlMetaIndex.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/MlMetaIndex.java @@ -32,7 +32,7 @@ public static String indexName() { public static String mapping() { return TemplateUtils.loadTemplate( "/ml/meta_index_mappings.json", - Build.current().version(), // Only needed for BWC with pre-8.10.0 nodes + Build.current().unqualifiedVersion(), // Only needed for BWC with pre-8.10.0 nodes MAPPINGS_VERSION_VARIABLE, Map.of("xpack.ml.managed.index.version", Integer.toString(META_INDEX_MAPPINGS_VERSION)) ); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/MlStatsIndex.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/MlStatsIndex.java index aef615267ce4d..cdfdcbe2d3506 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/MlStatsIndex.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/MlStatsIndex.java @@ -40,7 +40,7 @@ public static String wrappedMapping() { public static String mapping() { return TemplateUtils.loadTemplate( "/ml/stats_index_mappings.json", - Build.current().version(), // Only needed for BWC with pre-8.10.0 nodes + Build.current().unqualifiedVersion(), // Only needed for BWC with pre-8.10.0 nodes MAPPINGS_VERSION_VARIABLE, Map.of("xpack.ml.managed.index.version", Integer.toString(STATS_INDEX_MAPPINGS_VERSION)) ); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/annotations/AnnotationIndex.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/annotations/AnnotationIndex.java index 9cd865e20d93e..a82c1f2419052 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/annotations/AnnotationIndex.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/annotations/AnnotationIndex.java @@ -213,7 +213,7 @@ public static void createAnnotationsIndexIfNecessary( public static String annotationsMapping() { return TemplateUtils.loadTemplate( "/ml/annotations_index_mappings.json", - Build.current().version(), // Only needed for BWC with pre-8.10.0 nodes + Build.current().unqualifiedVersion(), // Only needed for BWC with pre-8.10.0 nodes MAPPINGS_VERSION_VARIABLE, Map.of("xpack.ml.managed.index.version", Integer.toString(ANNOTATION_INDEX_MAPPINGS_VERSION)) ); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/persistence/InferenceIndexConstants.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/persistence/InferenceIndexConstants.java index 8d45184409a86..6d91a1d7ed3b5 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/persistence/InferenceIndexConstants.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/persistence/InferenceIndexConstants.java @@ -51,7 +51,7 @@ public final class InferenceIndexConstants { public static String mapping() { return TemplateUtils.loadTemplate( "/ml/inference_index_mappings.json", - Build.current().version(), // Only needed for BWC with pre-8.10.0 nodes + Build.current().unqualifiedVersion(), // Only needed for BWC with pre-8.10.0 nodes MAPPINGS_VERSION_VARIABLE, Map.of("xpack.ml.managed.index.version", Integer.toString(INFERENCE_INDEX_MAPPINGS_VERSION)) ); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/persistence/AnomalyDetectorsIndex.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/persistence/AnomalyDetectorsIndex.java index d66aa2884280f..2de42a3938f91 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/persistence/AnomalyDetectorsIndex.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/persistence/AnomalyDetectorsIndex.java @@ -137,7 +137,7 @@ public static String wrappedResultsMapping() { public static String resultsMapping() { return TemplateUtils.loadTemplate( RESOURCE_PATH + "results_index_mappings.json", - Build.current().version(), // Only needed for BWC with pre-8.10.0 nodes + Build.current().unqualifiedVersion(), // Only needed for BWC with pre-8.10.0 nodes RESULTS_MAPPINGS_VERSION_VARIABLE, Map.of("xpack.ml.managed.index.version", Integer.toString(RESULTS_INDEX_MAPPINGS_VERSION)) ); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/notifications/NotificationsIndex.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/notifications/NotificationsIndex.java index 675cd1f377bf9..bf3472b126baa 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/notifications/NotificationsIndex.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/notifications/NotificationsIndex.java @@ -24,7 +24,7 @@ private NotificationsIndex() {} public static String mapping() { return TemplateUtils.loadTemplate( RESOURCE_PATH + "notifications_index_mappings.json", - Build.current().version(), // Only needed for BWC with pre-8.10.0 nodes + Build.current().unqualifiedVersion(), // Only needed for BWC with pre-8.10.0 nodes MAPPINGS_VERSION_VARIABLE, Map.of("xpack.ml.managed.index.version", Integer.toString(NOTIFICATIONS_INDEX_MAPPINGS_VERSION)) );