ES - Support for min_doc_count on group by terms (#7324)

This commit is contained in:
lpic 2017-01-23 07:26:42 +01:00 committed by Torkel Ödegaard
parent a0c8380baf
commit cf9790fc4c
3 changed files with 13 additions and 0 deletions

View File

@ -82,12 +82,17 @@ function (angular, _, queryDef) {
case 'terms': { case 'terms': {
settings.order = settings.order || "asc"; settings.order = settings.order || "asc";
settings.size = settings.size || "10"; settings.size = settings.size || "10";
settings.min_doc_count = settings.min_doc_count || 0;
settings.orderBy = settings.orderBy || "_term"; settings.orderBy = settings.orderBy || "_term";
if (settings.size !== '0') { if (settings.size !== '0') {
settingsLinkText = queryDef.describeOrder(settings.order) + ' ' + settings.size + ', '; settingsLinkText = queryDef.describeOrder(settings.order) + ' ' + settings.size + ', ';
} }
if (settings.min_doc_count > 0) {
settingsLinkText += 'Min Doc Count: ' + settings.min_doc_count + ', ';
}
settingsLinkText += 'Order by: ' + queryDef.describeOrderBy(settings.orderBy, $scope.target); settingsLinkText += 'Order by: ' + queryDef.describeOrderBy(settings.orderBy, $scope.target);
if (settings.size === '0') { if (settings.size === '0') {

View File

@ -61,6 +61,10 @@
<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">
<label class="gf-form-label width-10">Min Doc Count</label>
<input type="number" class="gf-form-input max-width-12" ng-model="agg.settings.min_doc_count" ng-blur="onChangeInternal()">
</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>

View File

@ -49,6 +49,10 @@ function (queryDef) {
} }
} }
if (aggDef.settings.min_doc_count !== void 0) {
queryNode.terms.min_doc_count = parseInt(aggDef.settings.min_doc_count, 10);
}
if (aggDef.settings.missing) { if (aggDef.settings.missing) {
queryNode.terms.missing = aggDef.settings.missing; queryNode.terms.missing = aggDef.settings.missing;
} }