[ML] Do not serialize rules when empty (elastic/x-pack-elasticsearch#4203)

Original commit: elastic/x-pack-elasticsearch@18d731cb35
This commit is contained in:
Dimitris Athanasiou 2018-03-23 11:21:27 +00:00 committed by GitHub
parent f6d318a782
commit c4ff5ad3ed
1 changed files with 3 additions and 1 deletions

View File

@ -292,7 +292,9 @@ public class Detector implements ToXContentObject, Writeable {
if (excludeFrequent != null) {
builder.field(EXCLUDE_FREQUENT_FIELD.getPreferredName(), excludeFrequent);
}
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