Commit 2c75593c by Torkel Ödegaard

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

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