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) { ...@@ -103,6 +103,8 @@ function (angular, _, queryDef) {
break; break;
} }
case 'raw_document': { 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.metrics = [$scope.agg];
$scope.target.bucketAggs = []; $scope.target.bucketAggs = [];
break; break;
......
...@@ -72,6 +72,11 @@ ...@@ -72,6 +72,11 @@
<label class="gf-form-label width-10">Percentiles</label> <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> <input type="text" class="gf-form-input max-width-12" ng-model="agg.settings.percents" array-join ng-blur="onChange()"></input>
</div> </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'"> <div class="gf-form offset-width-7" ng-if="agg.type === 'cardinality'">
<label class="gf-form-label width-10">Precision threshold</label> <label class="gf-form-label width-10">Precision threshold</label>
......
...@@ -109,8 +109,8 @@ function (queryDef) { ...@@ -109,8 +109,8 @@ function (queryDef) {
return filterObj; return filterObj;
}; };
ElasticQueryBuilder.prototype.documentQuery = function(query) { ElasticQueryBuilder.prototype.documentQuery = function(query, size) {
query.size = 500; query.size = size === undefined ? 500 : parseInt(size , 10);
query.sort = {}; query.sort = {};
query.sort[this.timeField] = {order: 'desc', unmapped_type: 'boolean'}; query.sort[this.timeField] = {order: 'desc', unmapped_type: 'boolean'};
...@@ -196,7 +196,9 @@ function (queryDef) { ...@@ -196,7 +196,9 @@ function (queryDef) {
if (metric && metric.type !== 'raw_document') { if (metric && metric.type !== 'raw_document') {
throw {message: 'Invalid query'}; 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; nestedAggs = query;
......
...@@ -156,13 +156,22 @@ describe('ElasticQueryBuilder', function() { ...@@ -156,13 +156,22 @@ describe('ElasticQueryBuilder', function() {
it('with raw_document metric', function() { it('with raw_document metric', function() {
var query = builder.build({ var query = builder.build({
metrics: [{type: 'raw_document', id: '1'}], metrics: [{type: 'raw_document', id: '1',settings: {}}],
timeField: '@timestamp', timeField: '@timestamp',
bucketAggs: [], bucketAggs: [],
}); });
expect(query.size).to.be(500); 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() { it('with moving average', function() {
var query = builder.build({ 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