Commit 2c75593c by Torkel Ödegaard

refactoring: elasticsearch raw doc size limit option PR, #8527

parent 3c41d047
...@@ -110,7 +110,7 @@ function (queryDef) { ...@@ -110,7 +110,7 @@ function (queryDef) {
}; };
ElasticQueryBuilder.prototype.documentQuery = function(query, size) { ElasticQueryBuilder.prototype.documentQuery = function(query, size) {
query.size = size === undefined ? 500 : size; query.size = size;
query.sort = {}; query.sort = {};
query.sort[this.timeField] = {order: 'desc', unmapped_type: 'boolean'}; query.sort[this.timeField] = {order: 'desc', unmapped_type: 'boolean'};
...@@ -193,13 +193,12 @@ function (queryDef) { ...@@ -193,13 +193,12 @@ function (queryDef) {
// handle document query // handle document query
if (target.bucketAggs.length === 0) { if (target.bucketAggs.length === 0) {
metric = target.metrics[0]; metric = target.metrics[0];
if (metric && metric.type !== 'raw_document') { if (!metric || metric.type !== 'raw_document') {
target.bucketAggs = [{type: 'date_histogram', id: '2', settings: {interval: 'auto'}}]; throw {message: 'Invalid query'};
} else {
var size = metric && metric.hasOwnProperty("settings") && metric.settings.hasOwnProperty("size")
&& metric.settings["size"] !== null ? metric.settings["size"] : 500 ;
return this.documentQuery(query,size);
} }
var size = (metric.settings && metric.settings.size) || 500;
return this.documentQuery(query, size);
} }
nestedAggs = query; nestedAggs = query;
......
...@@ -62,7 +62,7 @@ describe('ElasticDatasource', function() { ...@@ -62,7 +62,7 @@ describe('ElasticDatasource', function() {
from: moment.utc([2015, 4, 30, 10]), from: moment.utc([2015, 4, 30, 10]),
to: moment.utc([2015, 5, 1, 10]) to: moment.utc([2015, 5, 1, 10])
}, },
targets: [{ bucketAggs: [], metrics: [], query: 'escape\\:test' }] targets: [{ bucketAggs: [], metrics: [{type: 'raw_document'}], query: 'escape\\:test' }]
}); });
ctx.$rootScope.$apply(); ctx.$rootScope.$apply();
......
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