|
@@ -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) {
|
|
|
// 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') {
|
|
|
|
|
- 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;
|
|
nestedAggs = query;
|