|
@@ -17,14 +17,28 @@ function (angular, _, config) {
|
|
|
ids : [],
|
|
ids : [],
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- // Defaults for query objects
|
|
|
|
|
|
|
+ // Defaults for generic query object
|
|
|
var _query = {
|
|
var _query = {
|
|
|
- query: '*',
|
|
|
|
|
alias: '',
|
|
alias: '',
|
|
|
pin: false,
|
|
pin: false,
|
|
|
type: 'lucene'
|
|
type: 'lucene'
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ // Defaults for specific query types
|
|
|
|
|
+ var _dTypes = {
|
|
|
|
|
+ "lucene": {
|
|
|
|
|
+ query: "*"
|
|
|
|
|
+ },
|
|
|
|
|
+ "regex": {
|
|
|
|
|
+ query: ".*"
|
|
|
|
|
+ },
|
|
|
|
|
+ "derive": {
|
|
|
|
|
+ query: "*",
|
|
|
|
|
+ field: "_type",
|
|
|
|
|
+ size: "5"
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
// For convenience
|
|
// For convenience
|
|
|
var ejs = ejsResource(config.elasticsearch);
|
|
var ejs = ejsResource(config.elasticsearch);
|
|
|
var _q = dashboard.current.services.query;
|
|
var _q = dashboard.current.services.query;
|
|
@@ -80,6 +94,7 @@ function (angular, _, config) {
|
|
|
query.id = _id;
|
|
query.id = _id;
|
|
|
query.color = query.color || colorAt(_id);
|
|
query.color = query.color || colorAt(_id);
|
|
|
_.defaults(query,_query);
|
|
_.defaults(query,_query);
|
|
|
|
|
+ _.defaults(query,_dTypes[query.type]);
|
|
|
|
|
|
|
|
self.list[_id] = query;
|
|
self.list[_id] = query;
|
|
|
self.ids.push(_id);
|
|
self.ids.push(_id);
|
|
@@ -102,10 +117,13 @@ function (angular, _, config) {
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- this.getEjsObj = function(id) {
|
|
|
|
|
- return self.toEjsObj(self.list[id]);
|
|
|
|
|
|
|
+ // This must return an array to correctly resolve compound query types, eg derived
|
|
|
|
|
+ this.getEjsObj = function(ids) {
|
|
|
|
|
+ return self.toEjsObj(self.list[ids]);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ // In the case of a compound query, such as a derived query, we'd need to
|
|
|
|
|
+ // return an array of elasticJS objects. Not sure if that is appropriate?
|
|
|
this.toEjsObj = function (q) {
|
|
this.toEjsObj = function (q) {
|
|
|
switch(q.type)
|
|
switch(q.type)
|
|
|
{
|
|
{
|