|
@@ -5,6 +5,7 @@
|
|
|
*/
|
|
|
package org.elasticsearch.xpack.core.ml.job.results;
|
|
|
|
|
|
+import org.elasticsearch.Version;
|
|
|
import org.elasticsearch.common.ParseField;
|
|
|
import org.elasticsearch.common.Strings;
|
|
|
import org.elasticsearch.common.io.stream.StreamInput;
|
|
@@ -55,6 +56,7 @@ public class AnomalyRecord implements ToXContentObject, Writeable {
|
|
|
public static final ParseField ACTUAL = new ParseField("actual");
|
|
|
public static final ParseField INFLUENCERS = new ParseField("influencers");
|
|
|
public static final ParseField BUCKET_SPAN = new ParseField("bucket_span");
|
|
|
+ public static final ParseField GEO_RESULTS = new ParseField("geo_results");
|
|
|
|
|
|
// Used for QueryPage
|
|
|
public static final ParseField RESULTS_FIELD = new ParseField("records");
|
|
@@ -114,6 +116,9 @@ public class AnomalyRecord implements ToXContentObject, Writeable {
|
|
|
CAUSES);
|
|
|
parser.declareObjectArray(AnomalyRecord::setInfluencers, ignoreUnknownFields ? Influence.LENIENT_PARSER : Influence.STRICT_PARSER,
|
|
|
INFLUENCERS);
|
|
|
+ parser.declareObject(AnomalyRecord::setGeoResults,
|
|
|
+ ignoreUnknownFields ? GeoResults.LENIENT_PARSER : GeoResults.STRICT_PARSER,
|
|
|
+ GEO_RESULTS);
|
|
|
|
|
|
return parser;
|
|
|
}
|
|
@@ -132,6 +137,7 @@ public class AnomalyRecord implements ToXContentObject, Writeable {
|
|
|
private List<Double> typical;
|
|
|
private List<Double> actual;
|
|
|
private boolean isInterim;
|
|
|
+ private GeoResults geoResults;
|
|
|
|
|
|
private String fieldName;
|
|
|
|
|
@@ -187,6 +193,9 @@ public class AnomalyRecord implements ToXContentObject, Writeable {
|
|
|
if (in.readBoolean()) {
|
|
|
influences = in.readList(Influence::new);
|
|
|
}
|
|
|
+ if (in.getVersion().onOrAfter(Version.V_8_0_0)) {
|
|
|
+ geoResults = in.readOptionalWriteable(GeoResults::new);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -230,6 +239,9 @@ public class AnomalyRecord implements ToXContentObject, Writeable {
|
|
|
if (hasInfluencers) {
|
|
|
out.writeList(influences);
|
|
|
}
|
|
|
+ if (out.getVersion().onOrAfter(Version.V_8_0_0)) {
|
|
|
+ out.writeOptionalWriteable(geoResults);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -295,6 +307,9 @@ public class AnomalyRecord implements ToXContentObject, Writeable {
|
|
|
if (influences != null) {
|
|
|
builder.field(INFLUENCERS.getPreferredName(), influences);
|
|
|
}
|
|
|
+ if (geoResults != null) {
|
|
|
+ builder.field(GEO_RESULTS.getPreferredName(), geoResults);
|
|
|
+ }
|
|
|
|
|
|
Map<String, LinkedHashSet<String>> inputFields = inputFieldMap();
|
|
|
for (String fieldName : inputFields.keySet()) {
|
|
@@ -524,6 +539,13 @@ public class AnomalyRecord implements ToXContentObject, Writeable {
|
|
|
this.influences = influencers;
|
|
|
}
|
|
|
|
|
|
+ public GeoResults getGeoResults() {
|
|
|
+ return geoResults;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setGeoResults(GeoResults geoResults) {
|
|
|
+ this.geoResults = geoResults;
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public int hashCode() {
|
|
@@ -531,10 +553,9 @@ public class AnomalyRecord implements ToXContentObject, Writeable {
|
|
|
initialRecordScore, typical, actual,function, functionDescription, fieldName,
|
|
|
byFieldName, byFieldValue, correlatedByFieldValue, partitionFieldName,
|
|
|
partitionFieldValue, overFieldName, overFieldValue, timestamp, isInterim,
|
|
|
- causes, influences, jobId);
|
|
|
+ causes, influences, jobId, geoResults);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
public boolean equals(Object other) {
|
|
|
if (this == other) {
|
|
@@ -569,6 +590,12 @@ public class AnomalyRecord implements ToXContentObject, Writeable {
|
|
|
&& Objects.equals(this.timestamp, that.timestamp)
|
|
|
&& Objects.equals(this.isInterim, that.isInterim)
|
|
|
&& Objects.equals(this.causes, that.causes)
|
|
|
+ && Objects.equals(this.geoResults, that.geoResults)
|
|
|
&& Objects.equals(this.influences, that.influences);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String toString() {
|
|
|
+ return Strings.toString(this, true, true);
|
|
|
+ }
|
|
|
}
|