adds support for moving avg support in es queries

This commit is contained in:
Carl Bergquist
2015-12-08 12:04:42 +01:00
parent e194461420
commit 0731064375
2 changed files with 46 additions and 3 deletions

View File

@@ -175,8 +175,28 @@ function () {
}
var aggField = {};
aggField[metric.type] = metricAgg;
nestedAggs.aggs[metric.id] = aggField;
if (metric.type === 'moving_avg') {
var pipeAgg = '';
for(var aggname in nestedAggs.aggs) {
var agg = nestedAggs.aggs[aggname];
for(prop in agg) {
if (agg.hasOwnProperty(prop) && agg[prop] !== null) {
if (metric.field === prop) {
pipeAgg = aggname;
break;
}
}
}
}
if (pipeAgg !== '') {
aggField[metric.type] = { buckets_path: pipeAgg };
nestedAggs.aggs[metric.id] = aggField;
}
} else {
aggField[metric.type] = metricAgg;
nestedAggs.aggs[metric.id] = aggField;
}
}
return query;
@@ -217,5 +237,4 @@ function () {
};
return ElasticQueryBuilder;
});