mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Merge pull request #8714 from elastic/jasper/backport/8691/5.0
[backport] PR #8691 to 5.0
This commit is contained in:
commit
d981b231e9
1 changed files with 13 additions and 1 deletions
|
@ -5,11 +5,23 @@ export default function buildPhraseFilter(field, value, indexPattern) {
|
|||
if (field.scripted) {
|
||||
// painless expects params.value while groovy and expression languages expect value.
|
||||
const valueClause = field.lang === 'painless' ? 'params.value' : 'value';
|
||||
|
||||
// See https://github.com/elastic/elasticsearch/issues/20941 and https://github.com/elastic/kibana/issues/8677
|
||||
// for the reason behind this change. ES doesn't handle boolean types very well, so they come
|
||||
// back as strings.
|
||||
let convertedValue = value;
|
||||
if (typeof value !== 'boolean' && field.type === 'boolean') {
|
||||
if (value !== 'true' && value !== 'false') {
|
||||
throw new Error('Boolean scripted fields must return true or false');
|
||||
}
|
||||
convertedValue = value === 'true' ? true : false;
|
||||
}
|
||||
|
||||
_.set(filter, 'script.script', {
|
||||
inline: '(' + field.script + ') == ' + valueClause,
|
||||
lang: field.lang,
|
||||
params: {
|
||||
value: value
|
||||
value: convertedValue
|
||||
}
|
||||
});
|
||||
filter.meta.field = field.name;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue