@spalger/kibana
Version:
Kibana is an open source (Apache Licensed), browser based analytics and search dashboard for Elasticsearch. Kibana is a snap to setup and start using. Kibana strives to be easy to get started with, while also being flexible and powerful, just like Elastic
48 lines (40 loc) • 1.19 kB
JavaScript
define(function () {
var i = 0;
function AggConfigResult(aggConfig, parent, value, key) {
this.key = key;
this.value = value;
this.aggConfig = aggConfig;
this.$parent = parent;
this.$order = ++i;
if (aggConfig.schema.group === 'buckets') {
this.type = 'bucket';
} else {
this.type = 'metric';
}
}
/**
* Returns an array of the aggConfigResult and parents up te branch
* @returns {array} Array of aggConfigResults
*/
AggConfigResult.prototype.getPath = function () {
return (function walk(result, path) {
path.unshift(result);
if (result.$parent) return walk(result.$parent, path);
return path;
}(this, []));
};
/**
* Returns an Elasticsearch filter that represents the result.
* @returns {object} Elasticsearch filter
*/
AggConfigResult.prototype.createFilter = function () {
return this.aggConfig.createFilter(this.key);
};
AggConfigResult.prototype.toString = function (contentType) {
return this.aggConfig.fieldFormatter(contentType)(this.value);
};
AggConfigResult.prototype.valueOf = function () {
return this.value;
};
return AggConfigResult;
});