Added parsing of other multifield values to field mapper. Terms panel now looks for a .raw if one exists and uses it.

This commit is contained in:
Rashid Khan 2013-12-16 17:19:54 -07:00
parent 48d5c91cb2
commit 072eda28c4
3 changed files with 21 additions and 9 deletions

View File

@ -19,6 +19,12 @@
</div>
<div><input type="text" class="input-medium" placeholder="Type to filter..." ng-model="fieldFilter"></div>
<div ng-show="panel.all_fields" class="small muted" style="margin-bottom:10px">
<strong>Note</strong> These fields have been<br>
extracted from your mapping.<br>
Not all fields may be available<br>
in your source document.
</div>
<ul class="unstyled" style="{{panel.overflow}}:{{panel.height || row.height}};overflow-y:auto;overflow-x:hidden;" ng-if="panel.all_fields">
<li ng-style="panel.style" ng-repeat="field in fields.list|filter:fieldFilter|orderBy:identity">

View File

@ -22,7 +22,7 @@ function (angular, app, _, $, kbn) {
var module = angular.module('kibana.panels.terms', []);
app.useModule(module);
module.controller('terms', function($scope, querySrv, dashboard, filterSrv) {
module.controller('terms', function($scope, querySrv, dashboard, filterSrv, fields) {
$scope.panelMeta = {
modals : [
{
@ -134,6 +134,9 @@ function (angular, app, _, $, kbn) {
boolQuery,
queries;
$scope.field = _.contains(fields.list,$scope.panel.field+'.raw') ?
$scope.panel.field+'.raw' : $scope.panel.field;
request = $scope.ejs.Request().indices(dashboard.indices);
$scope.panel.queries.ids = querySrv.idsByMode($scope.panel.queries);
@ -145,11 +148,10 @@ function (angular, app, _, $, kbn) {
boolQuery = boolQuery.should(querySrv.toEjsObj(q));
});
// Terms mode
request = request
.facet($scope.ejs.TermsFacet('terms')
.field($scope.panel.field)
.field($scope.field)
.size($scope.panel.size)
.order($scope.panel.order)
.exclude($scope.panel.exclude)
@ -187,10 +189,10 @@ function (angular, app, _, $, kbn) {
$scope.build_search = function(term,negate) {
if(_.isUndefined(term.meta)) {
filterSrv.set({type:'terms',field:$scope.panel.field,value:term.label,
filterSrv.set({type:'terms',field:$scope.field,value:term.label,
mandate:(negate ? 'mustNot':'must')});
} else if(term.meta === 'missing') {
filterSrv.set({type:'exists',field:$scope.panel.field,
filterSrv.set({type:'exists',field:$scope.field,
mandate:(negate ? 'must':'mustNot')});
} else {
return;

View File

@ -28,7 +28,6 @@ function (angular, _, config) {
self.indices = _.union(self.indices,_.keys(result));
self.list = mapFields(result);
});
// Otherwise just use the cached mapping
}
}
});
@ -76,13 +75,18 @@ function (angular, _, config) {
dot = (prefix) ? '.':'',
ret = {};
for(var attr in obj){
if(attr === 'dynamic_templates' || attr === '_default_') {
continue;
}
// For now only support multi field on the top level
// and if there is a default field set.
if(obj[attr]['type'] === 'multi_field') {
ret[attr] = obj[attr]['fields'][attr] || obj[attr];
continue;
}
if (attr === 'properties') {
var keys = _.without(_.keys(obj[attr]['fields']),attr);
for(var key in keys) {
ret[attr+'.'+keys[key]] = obj[attr]['fields'][keys[key]];
}
} else if (attr === 'properties') {
_.extend(ret,flatten(obj[attr], propName));
} else if(typeof obj[attr] === 'object'){
_.extend(ret,flatten(obj[attr], propName + dot + attr));