Elasticsearch: Fix empty query request to send properly (#17488)

* ensure that empty Elasticsearch queries are properly set to *.  Fixes issue that appears when passing raw data from variables.

* combine null check and empty check into one
This commit is contained in:
Dave 2019-06-13 09:45:31 -04:00 committed by Torkel Ödegaard
parent a2370a379d
commit c78b6e2a67

View File

@ -257,7 +257,11 @@ export class ElasticDatasource {
target.alias = this.templateSrv.replace(target.alias, options.scopedVars, 'lucene');
}
const queryString = this.templateSrv.replace(target.query || '*', options.scopedVars, 'lucene');
let queryString = this.templateSrv.replace(target.query, options.scopedVars, 'lucene');
// Elasticsearch queryString should always be '*' if empty string
if (!queryString || queryString === '') {
queryString = '*';
}
const queryObj = this.queryBuilder.build(target, adhocFilters, queryString);
const esQuery = angular.toJson(queryObj);