mirror of
https://github.com/elastic/kibana.git
synced 2025-04-25 02:09:32 -04:00
Merge pull request #4285 from rashidkpc/feature/order-by-term
Order by term in terms agg
This commit is contained in:
commit
41ab57ae85
2 changed files with 31 additions and 17 deletions
|
@ -28,7 +28,7 @@ define(function (require) {
|
|||
title: 'Terms',
|
||||
makeLabel: function (agg) {
|
||||
var params = agg.params;
|
||||
return params.order.display + ' ' + params.size + ' ' + params.field.displayName;
|
||||
return params.field.displayName + ': ' + params.order.display;
|
||||
},
|
||||
createFilter: createFilter,
|
||||
params: [
|
||||
|
@ -53,21 +53,6 @@ define(function (require) {
|
|||
name: 'size',
|
||||
default: 5
|
||||
},
|
||||
{
|
||||
name: 'order',
|
||||
type: 'optioned',
|
||||
default: 'desc',
|
||||
editor: require('text!components/agg_types/controls/order_and_size.html'),
|
||||
options: [
|
||||
{ display: 'Top', val: 'desc' },
|
||||
{ display: 'Bottom', val: 'asc' }
|
||||
],
|
||||
write: _.noop // prevent default write, it's handled by orderAgg
|
||||
},
|
||||
{
|
||||
name: 'orderBy',
|
||||
write: _.noop // prevent default write, it's handled by orderAgg
|
||||
},
|
||||
{
|
||||
name: 'orderAgg',
|
||||
type: AggConfig,
|
||||
|
@ -122,6 +107,12 @@ define(function (require) {
|
|||
// we aren't creating a custom aggConfig
|
||||
if (!orderBy || orderBy !== 'custom') {
|
||||
params.orderAgg = null;
|
||||
|
||||
if (orderBy === '_term') {
|
||||
params.orderBy = '_term';
|
||||
return;
|
||||
}
|
||||
|
||||
// ensure that orderBy is set to a valid agg
|
||||
if (!_.find($scope.responseValueAggs, { id: orderBy })) {
|
||||
params.orderBy = null;
|
||||
|
@ -146,7 +137,12 @@ define(function (require) {
|
|||
output.params.valueType = agg.field().type === 'number' ? 'float' : agg.field().type;
|
||||
}
|
||||
|
||||
if (!orderAgg || orderAgg.type.name === 'count') {
|
||||
if (!orderAgg) {
|
||||
order[agg.params.orderBy || '_count'] = dir;
|
||||
return;
|
||||
}
|
||||
|
||||
if (orderAgg.type.name === 'count') {
|
||||
order._count = dir;
|
||||
return;
|
||||
}
|
||||
|
@ -159,6 +155,21 @@ define(function (require) {
|
|||
output.subAggs = (output.subAggs || []).concat(orderAgg);
|
||||
order[orderAggId] = dir;
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'order',
|
||||
type: 'optioned',
|
||||
default: 'desc',
|
||||
editor: require('text!components/agg_types/controls/order_and_size.html'),
|
||||
options: [
|
||||
{ display: 'Descending', val: 'desc' },
|
||||
{ display: 'Ascending', val: 'asc' }
|
||||
],
|
||||
write: _.noop // prevent default write, it's handled by orderAgg
|
||||
},
|
||||
{
|
||||
name: 'orderBy',
|
||||
write: _.noop // prevent default write, it's handled by orderAgg
|
||||
}
|
||||
]
|
||||
});
|
||||
|
|
|
@ -15,6 +15,9 @@
|
|||
<option value="custom" ng-selected="agg.params.orderBy === 'custom'">
|
||||
Custom Metric
|
||||
</option>
|
||||
<option value="_term" ng-selected="agg.params.orderBy === '_term'">
|
||||
Term
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<div ng-show="agg.params.orderAgg" class="vis-editor-agg-order-agg">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue