From e1a610dd582344137686a76a5ff3ec7aededde58 Mon Sep 17 00:00:00 2001 From: "iana.bondarska" Date: Wed, 10 Apr 2019 22:17:57 +0200 Subject: [PATCH] Can't create anomaly detector that uses "_index" as "partition_field_name" #39406 --- .../xpack/core/ml/job/results/ReservedFieldNames.java | 8 ++++++-- .../xpack/ml/job/results/ReservedFieldNamesTests.java | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/ReservedFieldNames.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/ReservedFieldNames.java index 333b87b0c294f..87ccbc3bdc67c 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/ReservedFieldNames.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/results/ReservedFieldNames.java @@ -5,6 +5,7 @@ */ package org.elasticsearch.xpack.core.ml.job.results; +import org.elasticsearch.index.get.GetResult; import org.elasticsearch.xpack.core.ml.datafeed.ChunkingConfig; import org.elasticsearch.xpack.core.ml.datafeed.DatafeedConfig; import org.elasticsearch.xpack.core.ml.datafeed.DelayedDataCheckConfig; @@ -171,8 +172,11 @@ public final class ReservedFieldNames { Result.RESULT_TYPE.getPreferredName(), Result.TIMESTAMP.getPreferredName(), - Result.IS_INTERIM.getPreferredName() - }; + Result.IS_INTERIM.getPreferredName(), + GetResult._ID, + GetResult._INDEX, + GetResult._TYPE + }; /** * This array should be updated to contain all the field names that appear diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/results/ReservedFieldNamesTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/results/ReservedFieldNamesTests.java index a08b53fba3c0d..d594404e9c284 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/results/ReservedFieldNamesTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/results/ReservedFieldNamesTests.java @@ -5,6 +5,7 @@ */ package org.elasticsearch.xpack.ml.job.results; +import org.elasticsearch.index.get.GetResult; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.xpack.core.ml.job.results.AnomalyRecord; import org.elasticsearch.xpack.core.ml.job.results.ReservedFieldNames; @@ -16,5 +17,8 @@ public void testIsValidFieldName() { assertTrue(ReservedFieldNames.isValidFieldName("host.actual")); assertFalse(ReservedFieldNames.isValidFieldName("actual.host")); assertFalse(ReservedFieldNames.isValidFieldName(AnomalyRecord.BUCKET_SPAN.getPreferredName())); + assertFalse(ReservedFieldNames.isValidFieldName(GetResult._INDEX)); + assertFalse(ReservedFieldNames.isValidFieldName(GetResult._TYPE)); + assertFalse(ReservedFieldNames.isValidFieldName(GetResult._ID)); } -} \ No newline at end of file +}