Skip to content

Commit 7b68e6e

Browse files
committed
feat(elasticsearch): Added support for Missing option (bucket) for terms aggregation, refactoring PR grafana#4244, thx @shanielh
2 parents dd432e6 + f121e83 commit 7b68e6e

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

public/app/plugins/datasource/elasticsearch/bucket_agg.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ function (angular, _, queryDef) {
2727

2828
$scope.orderByOptions = [];
2929
$scope.bucketAggTypes = queryDef.bucketAggTypes;
30+
$scope.bucketAggTypesHash = _.indexBy(queryDef.bucketAggTypes, 'value');
3031
$scope.orderOptions = queryDef.orderOptions;
3132
$scope.sizeOptions = queryDef.sizeOptions;
3233

public/app/plugins/datasource/elasticsearch/partials/bucket_agg.html

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,23 @@
5757
<label class="gf-form-label width-10">Order</label>
5858
<metric-segment-model property="agg.settings.order" options="orderOptions" on-change="onChangeInternal()" css-class="width-12"></metric-segment-model>
5959
</div>
60-
6160
<div class="gf-form offset-width-7">
6261
<label class="gf-form-label width-10">Size</label>
6362
<metric-segment-model property="agg.settings.size" options="sizeOptions" on-change="onChangeInternal()" css-class="width-12"></metric-segment-model>
6463
</div>
65-
6664
<div class="gf-form offset-width-7">
6765
<label class="gf-form-label width-10">Order By</label>
6866
<metric-segment-model property="agg.settings.orderBy" options="orderByOptions" on-change="onChangeInternal()" css-class="width-12"></metric-segment-model>
6967
</div>
68+
<div class="gf-form offset-width-7">
69+
<label class="gf-form-label width-10">
70+
Missing
71+
<info-popover mode="right-normal">
72+
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
73+
</info-popover>
74+
</label>
75+
<input type="text" class="gf-form-input max-width-12" empty-to-null ng-model="agg.settings.missing" ng-blur="onChangeInternal()" spellcheck='false'>
76+
</div>
7077
</div>
7178

7279
<div ng-if="agg.type === 'filters'">
@@ -94,5 +101,3 @@
94101
</div>
95102

96103
</div>
97-
98-

public/app/plugins/datasource/elasticsearch/query_builder.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ function (queryDef) {
4848
}
4949
}
5050

51+
if (aggDef.settings.missing) {
52+
queryNode.terms.missing = aggDef.settings.missing;
53+
}
54+
5155
return queryNode;
5256
};
5357

@@ -67,6 +71,10 @@ function (queryDef) {
6771
esAgg.format = "epoch_millis";
6872
}
6973

74+
if (settings.missing) {
75+
esAgg.missing = settings.missing;
76+
}
77+
7078
return esAgg;
7179
};
7280

0 commit comments

Comments
 (0)