mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Update scripted bool filter workaround
https://github.com/elastic/kibana/pull/8691 fixed the creation of filters on boolean scripted fields when clicking on a visualization. The issue was caused by the fact that aggregations would return strings ("true"/"false") instead of actual booleans as their bucket key. This behavior occurred because Elasticsearch didn't support the `"valueType": "boolean"` flag we were sending. Elasticsearch now understands that (flag)[1] but as a (result)[2] it returns 1 and 0 instead of "true" and "false". Eventually we'll get actual boolean values, but we'll have to (wait)[3] till 6.0. So this PR simply updates our workaround to check for 1/0 instead of "true"/"false". [1]: https://github.com/elastic/elasticsearch/pull/22135 [2]: https://github.com/elastic/elasticsearch/pull/22201 [3]: https://github.com/elastic/elasticsearch/pull/22201#issuecomment-268634732
This commit is contained in:
parent
899d560caf
commit
8eea4dd9c9
1 changed files with 4 additions and 4 deletions
|
@ -4,14 +4,14 @@ export default function buildPhraseFilter(field, value, indexPattern) {
|
|||
|
||||
if (field.scripted) {
|
||||
// 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.
|
||||
// and https://github.com/elastic/elasticsearch/pull/22201
|
||||
// for the reason behind this change. Aggs now return boolean buckets with a key of 1 or 0.
|
||||
let convertedValue = value;
|
||||
if (typeof value !== 'boolean' && field.type === 'boolean') {
|
||||
if (value !== 'true' && value !== 'false') {
|
||||
if (value !== 1 && value !== 0) {
|
||||
throw new Error('Boolean scripted fields must return true or false');
|
||||
}
|
||||
convertedValue = value === 'true' ? true : false;
|
||||
convertedValue = value === 1 ? true : false;
|
||||
}
|
||||
|
||||
const script = buildInlineScriptForPhraseFilter(field);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue