feat(elasticsearch): Added support for Missing option (bucket) for terms aggregation, refactoring PR #4244, thx @shanielh

This commit is contained in:
Torkel Ödegaard
2016-12-07 12:06:47 +01:00
3 changed files with 18 additions and 4 deletions
@@ -27,6 +27,7 @@ function (angular, _, queryDef) {
$scope.orderByOptions = []; $scope.orderByOptions = [];
$scope.bucketAggTypes = queryDef.bucketAggTypes; $scope.bucketAggTypes = queryDef.bucketAggTypes;
$scope.bucketAggTypesHash = _.indexBy(queryDef.bucketAggTypes, 'value');
$scope.orderOptions = queryDef.orderOptions; $scope.orderOptions = queryDef.orderOptions;
$scope.sizeOptions = queryDef.sizeOptions; $scope.sizeOptions = queryDef.sizeOptions;
@@ -57,16 +57,23 @@
<label class="gf-form-label width-10">Order</label> <label class="gf-form-label width-10">Order</label>
<metric-segment-model property="agg.settings.order" options="orderOptions" on-change="onChangeInternal()" css-class="width-12"></metric-segment-model> <metric-segment-model property="agg.settings.order" options="orderOptions" on-change="onChangeInternal()" css-class="width-12"></metric-segment-model>
</div> </div>
<div class="gf-form offset-width-7"> <div class="gf-form offset-width-7">
<label class="gf-form-label width-10">Size</label> <label class="gf-form-label width-10">Size</label>
<metric-segment-model property="agg.settings.size" options="sizeOptions" on-change="onChangeInternal()" css-class="width-12"></metric-segment-model> <metric-segment-model property="agg.settings.size" options="sizeOptions" on-change="onChangeInternal()" css-class="width-12"></metric-segment-model>
</div> </div>
<div class="gf-form offset-width-7"> <div class="gf-form offset-width-7">
<label class="gf-form-label width-10">Order By</label> <label class="gf-form-label width-10">Order By</label>
<metric-segment-model property="agg.settings.orderBy" options="orderByOptions" on-change="onChangeInternal()" css-class="width-12"></metric-segment-model> <metric-segment-model property="agg.settings.orderBy" options="orderByOptions" on-change="onChangeInternal()" css-class="width-12"></metric-segment-model>
</div> </div>
<div class="gf-form offset-width-7">
<label class="gf-form-label width-10">
Missing
<info-popover mode="right-normal">
The missing parameter defines how documents that are missing a value should be treated. By default they will be ignored but it is also possible to treat them as if they had a value
</info-popover>
</label>
<input type="text" class="gf-form-input max-width-12" empty-to-null ng-model="agg.settings.missing" ng-blur="onChangeInternal()" spellcheck='false'>
</div>
</div> </div>
<div ng-if="agg.type === 'filters'"> <div ng-if="agg.type === 'filters'">
@@ -94,5 +101,3 @@
</div> </div>
</div> </div>
@@ -48,6 +48,10 @@ function (queryDef) {
} }
} }
if (aggDef.settings.missing) {
queryNode.terms.missing = aggDef.settings.missing;
}
return queryNode; return queryNode;
}; };
@@ -67,6 +71,10 @@ function (queryDef) {
esAgg.format = "epoch_millis"; esAgg.format = "epoch_millis";
} }
if (settings.missing) {
esAgg.missing = settings.missing;
}
return esAgg; return esAgg;
}; };