elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.68k stars 8.23k forks source link

Visualizations display "0" and "1" for boolean fields with a static lookup formatter #100832

Open n0othing opened 3 years ago

n0othing commented 3 years ago

Kibana version: 7.13

Elasticsearch version: 7.13

Describe the bug:

Visualizations display "0" and "1" for boolean fields with a static lookup formatter. Classic Visualize's pie chart behaves extra weird.

Steps to reproduce:

  1. Create an index with a boolean data type
    PUT index
    {
    "mappings": {
    "properties": {
      "boolean_field": {
        "type": "boolean"
      }
    }
    }
    }
    
    POST index/_doc?refresh
    {
    "boolean_field": true
    }

POST index/_doc?refresh { "boolean_field": false }


2. Add `index` as an index pattern in Kibana
3. Apply a Static Lookup field formatter like so:
![static_lookup](https://user-images.githubusercontent.com/11917935/119900148-19513100-bf12-11eb-83e0-8d35191c1c13.jpg)
4. Build a Visualize > Pie Chart, performing a terms agg on `boolean_field`. The pie chart shows `0` and `1` in the legend and the chart goes black. Similar behavior in Lens (but colors don't go black). Removing the formatter makes things behave normally (e.g the legend displays `true` and `false`).

**Screenshots (if relevant):**

![pie_chart](https://user-images.githubusercontent.com/11917935/119900434-849b0300-bf12-11eb-8c9c-a6d1b53921f5.jpg)

![Lens_boolean](https://user-images.githubusercontent.com/11917935/119900554-ad22fd00-bf12-11eb-875f-ee019ea0b66f.jpg)
elasticmachine commented 3 years ago

Pinging @elastic/kibana-app (Team:KibanaApp)

flash1293 commented 3 years ago

This is a bug in field formatters, not visualizations. I agree that true and false mapping should work as implied in the description.

heysulo commented 2 years ago

any update on this?

elasticmachine commented 1 year ago

Pinging @elastic/kibana-data-discovery (Team:DataDiscovery)

beningodfrey4 commented 1 day ago

For anyone still encountering this issue, a workaround is to create a scripted field of "Type: number" and "Format: Static Lookup".

Add entries for 0 and 1 mapping to the string you want for false and true correspondingly.

Then the script can just be return params._source.<original_bool_field>.