Commit 9de016bf by Torkel Ödegaard

feat(elasticseach): alias and lucene query fields are now visible/usable when…

feat(elasticseach): alias and lucene query fields are now visible/usable when using raw json query, #1034
parent 3eddfc02
...@@ -158,10 +158,10 @@ function (angular, _, moment, kbn, ElasticQueryBuilder, IndexPattern, ElasticRes ...@@ -158,10 +158,10 @@ function (angular, _, moment, kbn, ElasticQueryBuilder, IndexPattern, ElasticRes
target = options.targets[i]; target = options.targets[i];
if (target.hide) {return;} if (target.hide) {return;}
var esQuery = this.queryBuilder.build(target); var esQuery = angular.toJson(this.queryBuilder.build(target));
payload += header + '\n'; esQuery = esQuery.replace("$lucene_query", target.query || '*');
payload += angular.toJson(esQuery) + '\n';
payload += header + '\n' + esQuery + '\n';
sentTargets.push(target); sentTargets.push(target);
} }
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
</li> </li>
</ul> </ul>
<ul class="tight-form-list" ng-hide="target.rawQuery"> <ul class="tight-form-list">
<li class="tight-form-item query-keyword" style="width: 75px"> <li class="tight-form-item query-keyword" style="width: 75px">
Query Query
</li> </li>
......
...@@ -67,7 +67,7 @@ function (angular) { ...@@ -67,7 +67,7 @@ function (angular) {
"query": { "query": {
"query_string": { "query_string": {
"analyze_wildcard": true, "analyze_wildcard": true,
"query": target.query || '*' , "query": '$lucene_query',
} }
}, },
"filter": { "filter": {
......
...@@ -21,6 +21,14 @@ define([ ...@@ -21,6 +21,14 @@ define([
expect(query.aggs["1"].date_histogram.extended_bounds.min).to.be("$timeFrom"); expect(query.aggs["1"].date_histogram.extended_bounds.min).to.be("$timeFrom");
}); });
it('with raw query', function() {
var query = builder.build({
rawQuery: '{"query": "$lucene_query"}',
});
expect(query.query).to.be("$lucene_query");
});
it('with multiple bucket aggs', function() { it('with multiple bucket aggs', function() {
var query = builder.build({ var query = builder.build({
metrics: [{type: 'count', id: '1'}], metrics: [{type: 'count', id: '1'}],
......
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