elastic / kibana

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

[Lens] support both sorting and array values on last value dimensions #167528

Open drewdaemon opened 12 months ago

drewdaemon commented 12 months ago

Describe the feature: When users are dealing with a Last value dimension, they currently have the choice between displaying array values and allowing the dimension to be used as the sort-by for a top values dimension.

Not supporting array values

Screenshot 2023-09-28 at 9 14 42 AM

Supporting array values

Screenshot 2023-09-28 at 9 14 53 AM

While it wasn't the original reason we added this, the tradeoff actually makes sense because it is not clear how sorting by array values should work. It could

However, the behavior when not supporting array values is currently not ideal. The displayed values are computed from each array based on an undefined Elasticsearch operation. When users attempt to filter by these values, they see strange behavior since the filtered values don't actually exist in the data.

Instead of providing the tradeoff switch, we should support sorting by array values by making the sorting behavior explicit.

This will allow us to both order top values by a last value dimension and display correct values

elasticmachine commented 12 months ago

Pinging @elastic/kibana-visualizations (Team:Visualizations)

ppisljar commented 11 months ago

if i understand the issue correctly, the problem with top hits is that it does not support sorting ? one way to work around that would be to keep using top hits, then create a runtime field (on-the-fly) that reduces the multivalue field into a single value (average, sum, min, max, count of values. ...) and then use that field for sorting.

i am guessing es does a similar thing behind the scenes in top metrics agg (reduces the multivalue field using average) so it can sort on that value.

in lens this could happen completely transparent to the user.