Skip to content

Commit f121e83

Browse files
committed
ElasticSearch Terms & Date Histogram: Support 'missing' setting
1 parent 1d8222e commit f121e83

File tree

4 files changed

+40
-9
lines changed

4 files changed

+40
-9
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: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
</ul>
5858
<div class="clearfix"></div>
5959
</div>
60-
<div class="tight-form last">
60+
<div class="tight-form">
6161
<ul class="tight-form-list">
6262
<li class="tight-form-item" style="width: 170px">
6363
Trim edges points
@@ -71,11 +71,23 @@
7171
</ul>
7272
<div class="clearfix"></div>
7373
</div>
74+
<div class="tight-form last">
75+
<ul class="tight-form-list">
76+
<li class="tight-form-item" style="width: 170px;">
77+
Missing
78+
<tip>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</tip>
79+
</li>
80+
<li>
81+
<input type="text" class="tight-form-input last" empty-to-null ng-model="agg.settings.missing" ng-blur="onChangeInternal()" spellcheck='false'>
82+
</li>
83+
</ul>
84+
<div class="clearfix"></div>
85+
</div>
7486
</div>
7587
<div class="tight-form-inner-box" ng-if="agg.type === 'terms'">
7688
<div class="tight-form">
7789
<ul class="tight-form-list">
78-
<li class="tight-form-item" style="width: 60px">
90+
<li class="tight-form-item" style="width: 100px">
7991
Order
8092
</li>
8193
<li>
@@ -86,7 +98,7 @@
8698
</div>
8799
<div class="tight-form">
88100
<ul class="tight-form-list">
89-
<li class="tight-form-item" style="width: 60px">
101+
<li class="tight-form-item" style="width: 100px">
90102
Size
91103
</li>
92104
<li>
@@ -95,9 +107,9 @@
95107
</ul>
96108
<div class="clearfix"></div>
97109
</div>
98-
<div class="tight-form last">
110+
<div class="tight-form">
99111
<ul class="tight-form-list">
100-
<li class="tight-form-item" style="width: 60px">
112+
<li class="tight-form-item" style="width: 100px">
101113
Order By
102114
</li>
103115
<li>
@@ -106,6 +118,18 @@
106118
</ul>
107119
<div class="clearfix"></div>
108120
</div>
121+
<div class="tight-form last">
122+
<ul class="tight-form-list">
123+
<li class="tight-form-item" style="width: 100px;">
124+
Missing
125+
<tip>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</tip>
126+
</li>
127+
<li>
128+
<input type="text" class="tight-form-input last" empty-to-null ng-model="agg.settings.missing" ng-blur="onChangeInternal()" spellcheck='false'>
129+
</li>
130+
</ul>
131+
<div class="clearfix"></div>
132+
</div>
109133
</div>
110134
<div class="tight-form-inner-box" ng-if="agg.type === 'filters'">
111135
<div class="tight-form" ng-repeat="filter in agg.settings.filters" ng-class="{last: $last}">
@@ -129,5 +153,3 @@
129153
</div>
130154

131155
</div>
132-
133-

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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ function (_) {
2020
],
2121

2222
bucketAggTypes: [
23-
{text: "Terms", value: 'terms' },
23+
{text: "Terms", value: 'terms', supportsMissing: true },
2424
{text: "Filters", value: 'filters' },
25-
{text: "Date Histogram", value: 'date_histogram' },
25+
{text: "Date Histogram", value: 'date_histogram', supportsMissing: true },
2626
],
2727

2828
orderByOptions: [

0 commit comments

Comments
 (0)