Commit 966c2912 by Dhia MOAKHAR

[elasticsearch] Add option for result set size in raw_dcument

 it allows to specify the result set size in raw_document.
 Example: table  panel could show more (or less) than 500 line if needed.
 Added test to spec
parent d47c4785
......@@ -103,6 +103,8 @@ function (angular, _, queryDef) {
break;
}
case 'raw_document': {
$scope.agg.settings.size = $scope.agg.settings.size || 500;
$scope.settingsLinkText = 'Size: ' + $scope.agg.settings.size ;
$scope.target.metrics = [$scope.agg];
$scope.target.bucketAggs = [];
break;
......
......@@ -72,6 +72,11 @@
<label class="gf-form-label width-10">Percentiles</label>
<input type="text" class="gf-form-input max-width-12" ng-model="agg.settings.percents" array-join ng-blur="onChange()"></input>
</div>
<div class="gf-form offset-width-7" ng-if="agg.type === 'raw_document'">
<label class="gf-form-label width-10">Size</label>
<input type="text" class="gf-form-input max-width-12" ng-model="agg.settings.size" ng-blur="onChange()"></input>
</div>
<div class="gf-form offset-width-7" ng-if="agg.type === 'cardinality'">
<label class="gf-form-label width-10">Precision threshold</label>
......
......@@ -109,8 +109,8 @@ function (queryDef) {
return filterObj;
};
ElasticQueryBuilder.prototype.documentQuery = function(query) {
query.size = 500;
ElasticQueryBuilder.prototype.documentQuery = function(query, size) {
query.size = size === undefined ? 500 : parseInt(size , 10);
query.sort = {};
query.sort[this.timeField] = {order: 'desc', unmapped_type: 'boolean'};
......@@ -196,7 +196,9 @@ function (queryDef) {
if (metric && metric.type !== 'raw_document') {
throw {message: 'Invalid query'};
}
return this.documentQuery(query, target);
var size = metric && metric.hasOwnProperty("settings") && metric.settings.hasOwnProperty("size")
&& metric.settings["size"] !== null ? metric.settings["size"] : 500 ;
return this.documentQuery(query,size);
}
nestedAggs = query;
......
......@@ -156,13 +156,22 @@ describe('ElasticQueryBuilder', function() {
it('with raw_document metric', function() {
var query = builder.build({
metrics: [{type: 'raw_document', id: '1'}],
metrics: [{type: 'raw_document', id: '1',settings: {}}],
timeField: '@timestamp',
bucketAggs: [],
});
expect(query.size).to.be(500);
});
it('with raw_document metric size set', function() {
var query = builder.build({
metrics: [{type: 'raw_document', id: '1',settings: {size: '1337'}}],
timeField: '@timestamp',
bucketAggs: [],
});
expect(query.size).to.be(1337);
});
it('with moving average', function() {
var query = builder.build({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment