Hi, I'm having trouble finding a nice intuitive way to filter an ESQL dashboard. Any ideas would be greatly appreciated !
I have two indices: buildings and rooms, where each room has a building Id. On the dashboard I have a table of all our rooms, and thats simply:
FROM rooms
| LOOKUP JOIN buildings ON buildingId
However, I also have some other visualisations such as a table of each building, with aggregations about its number of rooms. To avoid missing out buildings with 0 rooms, these visualisations are sourced from the buildings index, and then with have a lookup join to the rooms index:
FROM buildings
| LOOKUP JOIN rooms ON buildingId
| STATS roomCount = COUNT(roomName.keyword),
| SORT roomCount ASC
These are the visualisations causing me issues, as buildings doesn't have a roomName field and so we can't add a normal field filter to the dashboard (those filters are applied before the lookup join so would result in 0 results)
I've had some ideas around ESQL control variables but none have worked so far... Using an ESQL control variable, say '?roomName' with the query:
FROM rooms
| STATS BY roomName
we can filter the records after the lookup join is completed:
FROM buildings
| LOOKUP JOIN rooms ON buildingId
| WHERE MV_CONTAINS(?roomName, roomName)
This has been looking promising but the issues lie with the limitations around the control variable. Firstly, a control variable must have a value so we cannot leave it empty when the user enters this dashboard. For intuitive use, the dashboard needs to essentially be "unfiltered" when first seen.
Ideally we could have the 'Select All' button be the default values of the filter, as we cannot expect the users to setup that up themselves (also, I am unable to simply add all the possible values as I don't know what rooms the users have). Unfortunately, I don't think this is currently possible.
I was wondering if we could have a phony options: "All Rooms", that when selected, we would have the esql not apply the room name filter. I think this would be possible with an OR statement. However, I cannot find how to add a static value of "All Rooms" to the results returned from the control variable query...
Any ideas anyone has on this problem would be very helpful, thank you !
