From c4ff5ad3edfdd4e1c5870406fa7ec13af7cab813 Mon Sep 17 00:00:00 2001 From: Dimitris Athanasiou Date: Fri, 23 Mar 2018 11:21:27 +0000 Subject: [PATCH] [ML] Do not serialize rules when empty (elastic/x-pack-elasticsearch#4203) Original commit: elastic/x-pack-elasticsearch@18d731cb35fe1756eb3a085407004a8e80b9fe1b --- .../org/elasticsearch/xpack/core/ml/job/config/Detector.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/Detector.java b/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/Detector.java index bc7c03a3a7b..75b3d4daf8c 100644 --- a/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/Detector.java +++ b/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/Detector.java @@ -292,7 +292,9 @@ public class Detector implements ToXContentObject, Writeable { if (excludeFrequent != null) { builder.field(EXCLUDE_FREQUENT_FIELD.getPreferredName(), excludeFrequent); } - builder.field(RULES_FIELD.getPreferredName(), rules); + if (rules.isEmpty() == false) { + builder.field(RULES_FIELD.getPreferredName(), rules); + } // negative means "unknown", which should only happen for a 5.4 job if (detectorIndex >= 0 // no point writing this to cluster state, as the indexes will get reassigned on reload anyway