fix(elasticsearch): quote variable value in lucene variable mulit format, fixes #2828

pull/2836/head
Torkel Ödegaard 10 years ago
parent b80dc92ca5
commit a567939f78
  1. 5
      public/app/features/templating/templateSrv.js
  2. 5
      public/app/features/templating/templateValuesSrv.js
  3. 2
      public/test/specs/templateSrv-specs.js
  4. 2
      public/test/specs/templateValuesSrv-specs.js

@ -44,7 +44,10 @@ function (angular, _) {
return '(' + value.join('|') + ')';
}
case "lucene": {
return '(' + value.join(' OR ') + ')';
var quotedValues = _.map(value, function(val) {
return '\\\"' + val + '\\\"';
});
return '(' + quotedValues.join(' OR ') + ')';
}
case "pipe": {
return value.join('|');

@ -262,7 +262,10 @@ function (angular, _, kbn) {
break;
}
case 'lucene': {
allValue = '(' + _.pluck(variable.options, 'text').join(' OR ') + ')';
var quotedValues = _.map(variable.options, function(val) {
return '\\\"' + val.text + '\\\"';
});
allValue = '(' + quotedValues.join(' OR ') + ')';
break;
}
case 'regex values': {

@ -68,7 +68,7 @@ define([
value: ['test','test2'],
}
});
expect(result).to.be('(test OR test2)');
expect(result).to.be('(\\\"test\\\" OR \\\"test2\\\")');
});
it('multi value and regex format should render regex string', function() {

@ -321,7 +321,7 @@ define([
});
it('should add lucene glob', function() {
expect(scenario.variable.options[0].value).to.be('(backend1 OR backend2)');
expect(scenario.variable.options[0].value).to.be('(\\\"backend1\\\" OR \\\"backend2\\\")');
});
});

Loading…
Cancel
Save