elastic / kibana

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

[Discover][ES|QL] Clicking and creating a filter doesnt work correctly for multivalues fields #193015

Closed stratoula closed 17 hours ago

stratoula commented 3 weeks ago

Kibana version: 8.15+

Describe the bug:

It creates the wheer clause:

| WHERE `category`==Men's Accessories,Men's Clothing

which is invalid

You can replicate by clicking the table cell for the category

Image

The correct filter is

| WHERE `category`== "Men's Accessories" AND `category`== "Men's Clothing" 

My main concern for this is that I am not sure how easy is to detect that a field is a multivalue one

elasticmachine commented 3 weeks ago

Pinging @elastic/kibana-esql (Team:ESQL)

elasticmachine commented 3 weeks ago

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

davismcphee commented 3 weeks ago

My main concern for this is that I am not sure how easy is to detect that a field is a multivalue one

@stratoula would it work to just check if the field value is an array, or does that oversimplify it?

stratoula commented 3 weeks ago

We will see 😄

stratoula commented 3 weeks ago

I looked into it and:

FROM kibana_sample_data_ecommerce | WHERE `category.keyword`=="Women's Clothing" AND `category.keyword`=="Women's Shoes"

this won't return the document with the array value: [Women's Accessories, Women's Clothing] because multivalue filtering is not supported yet from ES side.

I think for now we should not allow the filtering for multivalue fields

stratoula commented 3 weeks ago

I can make the appendWhereClauseToESQLQuery to return undefined for multivalue fields.

This means that:

Image

We could make it smarter and hide the cell actions in case of multivalues but @davismcphee I am not super familiar with this piece of code and from a quick glance is not straight forward. I will open a PR with the behavior described above and you can follow up if you wish

Most possibly this behavior will be supported from full text search (QSTR function) which is going to be on snapshot releases quite soon so hopefully in 8.17 will be on GA and we could use it here.

drewdaemon commented 1 week ago

~Wouldn't ... | WHERE field IN ["Women's Accessories", "Women's Clothing"] work?~

Edit: Never mind I see now that you want an and

stratoula commented 1 week ago

Also the query above fails :)

stratoula commented 17 hours ago

We disabled it in table, chart, fields list and doc viewer. So I am closing it (I will create an ER to enable it when match function is on GA)