Skip to content

Feat: Filter groups - #34889

Merged
w33ble merged 19 commits into
elastic:masterfrom
w33ble:feat/filter-groups
May 22, 2019
Merged

w33ble merged 19 commits into
elastic:masterfrom
w33ble:feat/filter-groups

Conversation

@w33ble

@w33ble w33ble commented Apr 10, 2019 •

Copy link
Copy Markdown
Contributor

Closes #23117

Blocked by #34823 merged

Allow grouping of filters and group selection in the filters function.

Apr-18-2019 09-49-33-optimized

  • The filters function now accepts an argument, which is multi and has an unnamed alias. Use it to select which group(s) of filters you want to use, like filters group1 | demodata
  • The time picker and dropdown functions both take a filterGroup argument, which is passed along to the filter expression

Testing

Grouping works with simple string matching (case sensitive). If you specify a group (or many groups) on the filters function, only filters that belong to the group(s) will be applied. If no group is provided, it behaves like global filters do now.

The easiest way is to simply watch filter values update. Create 3 elements with the following expressions:

  1. filters
  2. filters group1
  3. filters group2

Now add a time picker or dropdown element (or both, or multiples of one or both... whatever you want). You will see filters applied to #1, but not #2 or #3.

Now add a filter group to one (or several) or the time pickers and/or dropdowns. You can use the sidebar, as in the gif above, and you should see both "group1" and "group2" in the dropdown. If you add a different filterGroup to any of the filter elements, that will show up in the dropdown as well.

You can also add filterGroups to the expression, by adding filterGroup=group1 to the timefilterControl/dropdownControl function, like in this example:

timefilterControl compact=true column=@timestamp filterGroup=group1 | render

Now that should show up in #1 (since that one is global) and #2. Change the value to group2 and it should show up in #1 and #3. Change it to some other value and it will again only show up in #1.

The value for filterGroup can be any string, and if you create other groups (ie. use a string other than "group1" and "group2"), they should show up in the dropdown on the sidebar as well.

To check using multiple groups, set at least one filter on each of group1 and group2. Now update #3 to this expression: filters group2 group1. #3 should now show filters in both group1 and group2, and match #1 (unless you've added more groups).

Be sure to try using filters with multiple groups, and adding multiple filters to a group.

Sidebar

The sidebar control for the groups will show a dropdown of all groups that exist on any filters, as well as any groups being consumed by any filters functions (even if they are nested), which makes it easy to pick existing groups from the sidebar. Users can also create new groups on the fly from the sidebar.

If the element already uses a filter, and it's the only one, and you change it, the old group value will no longer show up in the list. You will have to manually add it back. This is also demonstrated in the gif above.

@w33ble
w33ble force-pushed the feat/filter-groups branch from 53a1536 to e59c643 Compare April 10, 2019 21:45
@elasticmachine

Copy link
Copy Markdown
Contributor

💚 Build Succeeded

@w33ble
w33ble force-pushed the feat/filter-groups branch 2 times, most recently from e31dda1 to 19b397c Compare April 10, 2019 23:43

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unfortunately becoming a common pattern, where expression args need to be synced with the filter expression at render time. I made a helper but I'm not sure how to abstract it better ☹️

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might consider creating a discuss issue and referencing it here and elsewhere...?

@w33ble
w33ble force-pushed the feat/filter-groups branch from 19b397c to c45ad46 Compare April 10, 2019 23:47
@elasticmachine

Copy link
Copy Markdown
Contributor

💚 Build Succeeded

@elasticmachine

Copy link
Copy Markdown
Contributor

💚 Build Succeeded

@w33ble
w33ble force-pushed the feat/filter-groups branch from c45ad46 to b697db0 Compare April 16, 2019 19:56
@elasticmachine

Copy link
Copy Markdown
Contributor

💚 Build Succeeded

@w33ble
w33ble force-pushed the feat/filter-groups branch from b697db0 to b4161ff Compare April 18, 2019 17:01
@elasticmachine

Copy link
Copy Markdown
Contributor

💚 Build Succeeded

@w33ble
w33ble force-pushed the feat/filter-groups branch 2 times, most recently from 2132773 to 13995fe Compare April 18, 2019 18:04
@w33ble
w33ble changed the base branch from master to fix/set-filter April 18, 2019 18:05
@w33ble
w33ble requested review from cqliu1, crob611 and monfera April 18, 2019 18:06
@w33ble w33ble added Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas t// review v7.2.0 v8.0.0 labels Apr 18, 2019
@elasticmachine

Copy link
Copy Markdown
Contributor

Pinging @elastic/kibana-canvas

@w33ble
w33ble marked this pull request as ready for review April 18, 2019 18:07
@w33ble
w33ble requested a review from a team as a code owner April 18, 2019 18:07
@elastic elastic deleted a comment from elasticmachine Apr 18, 2019
@ryankeairns

Copy link
Copy Markdown
Contributor

@w33ble Can you provide some steps on how to use this? It's not clear to me how you name a group in order for it to display in the dropdown, and I'm also not sure what 'Create a group' does. Thanks for clarifying.

One quick note, do you think this would be used frequently enough that the input could just be displayed all the time as opposed to being behind the plus icon?

@w33ble

w33ble commented Apr 18, 2019

Copy link
Copy Markdown
Contributor Author

One quick note, do you think this would be used frequently enough that the input could just be displayed all the time as opposed to being behind the plus icon?

@ryankeairns hard to say. Seems like something that would get a bunch of use, but it's hard to tell. Having it show up by default would be easy though, just need to add it to the element expressions.

I'll add more details to the description, sorry about that.

@elastic elastic deleted a comment from elasticmachine Apr 18, 2019
@w33ble
w33ble force-pushed the feat/filter-groups branch from a84df84 to a465ee2 Compare May 22, 2019 18:47
@w33ble
w33ble changed the base branch from fix/set-filter to master May 22, 2019 18:48
@w33ble

w33ble commented May 22, 2019

Copy link
Copy Markdown
Contributor Author

@monfera good question. The other 2 blocker issues are fixed, but that one remains. #33605 still needs to get fixed, but it doesn't really stop this feature from working, so it's not actually a "blocker".

The filter value also still doesn't reliably update all the time, which may or may not be related to that issue. I spent some time in the past trying to figure out why it happens but wasn't successful, sadly.

@elasticmachine

Copy link
Copy Markdown
Contributor

💚 Build Succeeded

@elasticmachine

Copy link
Copy Markdown
Contributor

💚 Build Succeeded

@w33ble

w33ble commented May 22, 2019

Copy link
Copy Markdown
Contributor Author

Thanks to @cqliu1, I figured what new group values sometimes don't show up in the sidebar. I opened #36950 to track it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas t// v7.2.0 v8.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Filter grouping

6 participants