[ML] Hide partition_scores field if empty (elastic/x-pack-elasticsearch#1189)

Original commit: elastic/x-pack-elasticsearch@5dec266e0d
This commit is contained in:
David Kyle 2017-04-25 10:46:17 +01:00
parent 6c0613f36f
commit bd40dd36c9
2 changed files with 6 additions and 2 deletions

View File

@ -162,14 +162,16 @@ public class Bucket extends ToXContentToBytes implements Writeable {
builder.field(BUCKET_SPAN.getPreferredName(), bucketSpan);
builder.field(INITIAL_ANOMALY_SCORE.getPreferredName(), initialAnomalyScore);
builder.field(RECORD_COUNT.getPreferredName(), recordCount);
if (!records.isEmpty()) {
if (records.isEmpty() == false) {
builder.field(RECORDS.getPreferredName(), records);
}
builder.field(EVENT_COUNT.getPreferredName(), eventCount);
builder.field(IS_INTERIM.getPreferredName(), isInterim);
builder.field(BUCKET_INFLUENCERS.getPreferredName(), bucketInfluencers);
builder.field(PROCESSING_TIME_MS.getPreferredName(), processingTimeMs);
builder.field(PARTITION_SCORES.getPreferredName(), partitionScores);
if (partitionScores.isEmpty() == false) {
builder.field(PARTITION_SCORES.getPreferredName(), partitionScores);
}
builder.field(Result.RESULT_TYPE.getPreferredName(), RESULT_TYPE_VALUE);
builder.endObject();
return builder;

View File

@ -70,6 +70,8 @@ setup:
- match: { buckets.1.timestamp: 1470009600000 }
- match: { buckets.1.job_id: farequote}
- match: { buckets.1.result_type: bucket}
- is_false: buckets.0.partition_scores
- is_false: buckets.1.partition_scores
---
"Test get buckets given exclude_interim is false":