Commit 0fc7405b by Torkel Ödegaard

fix(elasticsearch): for query template variable when looking up terms without…

fix(elasticsearch): for query template variable when looking up terms without query, no longer relies on elasticsearch default field, fixes #3887
parent f79600b3
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
* **Playlist**: Fixed problem with play order not matching order defined in playlist, fixes [#5467](https://github.com/grafana/grafana/pull/5467) * **Playlist**: Fixed problem with play order not matching order defined in playlist, fixes [#5467](https://github.com/grafana/grafana/pull/5467)
* **Graph panel**: Fixed problem with auto decimals on y axis when datamin=datamax, fixes [#6070](https://github.com/grafana/grafana/pull/6070) * **Graph panel**: Fixed problem with auto decimals on y axis when datamin=datamax, fixes [#6070](https://github.com/grafana/grafana/pull/6070)
* **Snapshot**: Can view embedded panels/png rendered panels in snapshots without login, fixes [#3769](https://github.com/grafana/grafana/pull/3769) * **Snapshot**: Can view embedded panels/png rendered panels in snapshots without login, fixes [#3769](https://github.com/grafana/grafana/pull/3769)
* **Elasticsearch**: Fix for query template variable when looking up terms without query, no longer relies on elasticsearch default field, fixes [#3887](https://github.com/grafana/grafana/pull/3887)
# 3.1.2 (unreleased) # 3.1.2 (unreleased)
* **Templating**: Fixed issue when combining row & panel repeats, fixes [#5790](https://github.com/grafana/grafana/issues/5790) * **Templating**: Fixed issue when combining row & panel repeats, fixes [#5790](https://github.com/grafana/grafana/issues/5790)
......
...@@ -216,11 +216,6 @@ function (angular, _, moment, kbn, ElasticQueryBuilder, IndexPattern, ElasticRes ...@@ -216,11 +216,6 @@ function (angular, _, moment, kbn, ElasticQueryBuilder, IndexPattern, ElasticRes
}); });
}; };
function escapeForJson(value) {
var luceneQuery = JSON.stringify(value);
return luceneQuery.substr(1, luceneQuery.length - 2);
}
this.getFields = function(query) { this.getFields = function(query) {
return this._get('/_mapping').then(function(result) { return this._get('/_mapping').then(function(result) {
var typeMap = { var typeMap = {
...@@ -285,7 +280,6 @@ function (angular, _, moment, kbn, ElasticQueryBuilder, IndexPattern, ElasticRes ...@@ -285,7 +280,6 @@ function (angular, _, moment, kbn, ElasticQueryBuilder, IndexPattern, ElasticRes
var header = this.getQueryHeader('count', range.from, range.to); var header = this.getQueryHeader('count', range.from, range.to);
var esQuery = angular.toJson(this.queryBuilder.getTermsQuery(queryDef)); var esQuery = angular.toJson(this.queryBuilder.getTermsQuery(queryDef));
esQuery = esQuery.replace("$lucene_query", escapeForJson(queryDef.query));
esQuery = esQuery.replace(/\$timeFrom/g, range.from.valueOf()); esQuery = esQuery.replace(/\$timeFrom/g, range.from.valueOf());
esQuery = esQuery.replace(/\$timeTo/g, range.to.valueOf()); esQuery = esQuery.replace(/\$timeTo/g, range.to.valueOf());
esQuery = header + '\n' + esQuery + '\n'; esQuery = header + '\n' + esQuery + '\n';
......
...@@ -221,12 +221,6 @@ function (queryDef) { ...@@ -221,12 +221,6 @@ function (queryDef) {
"size": 0, "size": 0,
"query": { "query": {
"filtered": { "filtered": {
"query": {
"query_string": {
"analyze_wildcard": true,
"query": '$lucene_query',
}
},
"filter": { "filter": {
"bool": { "bool": {
"must": [{"range": this.getRangeFilter()}] "must": [{"range": this.getRangeFilter()}]
...@@ -235,6 +229,16 @@ function (queryDef) { ...@@ -235,6 +229,16 @@ function (queryDef) {
} }
} }
}; };
if (queryDef.query) {
query.query.filtered.query = {
"query_string": {
"analyze_wildcard": true,
"query": queryDef.query,
}
};
}
query.aggs = { query.aggs = {
"1": { "1": {
"terms": { "terms": {
......
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