Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't prevent filterable rows from being filterable #11628

Merged
merged 5 commits into from
May 9, 2017

Conversation

lukasolson
Copy link
Member

@lukasolson lukasolson commented May 5, 2017

Fixes #8678.

For some reason, the data table has only ever allowed filtering on rows that have some sort of field associated, which meant that when you aggregate using the "filters" bucket agg, you were not able to filter on the associated row. This was strange because if you had created the same visualization as a vertical bar chart, you could click on the bar to filter.

This PR simply removes the check that the row has a field associated with it, which means you can now create filters from the "filters" bucket aggregation!

Summary: Data tables using the "Filters" aggregation now allow you to click on a row to create a filter.

Before:

before

After:

after

@lukasolson lukasolson added :Discovery Feature:Filters Feature:Visualizations Generic visualization features (in case no more specific feature label is available) review v5.5.0 v6.0.0 labels May 5, 2017
@lukasolson lukasolson self-assigned this May 5, 2017
@lukasolson
Copy link
Member Author

yo jenkins, i'd really appreciate it if you'd test this

Bargs
Bargs previously requested changes May 5, 2017
&& contents.aggConfig.getField().filterable;

if (isCellContentFilterable) {
if (contents.type === 'bucket') {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ran into a couple issues but I think they have an easy fix.

  • This adds filter icons to agg buckets that don't support filtering, like geohash_grid:

screen shot 2017-05-05 at 4 07 26 pm

We can check whether an agg type supports filtering with the following condition:

_.get(contents, 'aggConfig.type.createFilter')
  • This also adds filter icons to fields that are aggregatable, but not filterable, which will thrown an error if you try to filter on them. It's probably not common, but it's possible if you had a mapping like this:
PUT aggnofilter
{
  "mappings": {
    "aggnofilter": {
      "properties": { 
      "notindexed": {
        "type": "integer",
        "index": false
      }
      }
    }
  }
}

We can also check for this with the following condition:

(contents.aggConfig.getField() ? contents.aggConfig.getField().filterable : true);

Putting it altogether, we can write this condition as follows:

const isCellContentFilterable =
  contents.type === 'bucket'
  && _.get(contents, 'aggConfig.type.createFilter')
  && (contents.aggConfig.getField() ? contents.aggConfig.getField().filterable : true);

Copy link
Member Author

Choose a reason for hiding this comment

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

Awesome, thanks @Bargs

Copy link
Member Author

Choose a reason for hiding this comment

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

Do I really need to check if contents.type === 'bucket' if I'm checking _.get(contents, 'aggConfig.type.createFilter')?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not 100% sure, but that sounds right.

@Bargs
Copy link
Contributor

Bargs commented May 5, 2017

Oh, one other thing, it would be really cool if the agg's filter labels became filter aliases. But that's just a nice to have, we could add it some time in a separate PR.

@lukasolson lukasolson dismissed Bargs’s stale review May 8, 2017 17:48

Made the requested changes

@lukasolson
Copy link
Member Author

@Bargs Ready for another look.

Copy link
Contributor

@thomasneirynck thomasneirynck left a comment

Choose a reason for hiding this comment

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

This is a neat addition!

minor comment, for your consideration

&& contents.aggConfig.getField()
&& contents.aggConfig.getField().filterable;
_.get(contents, 'aggConfig.type.createFilter')
&& (!field || field.filterable);

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd consider moving this check to the AggConfig type instead. Then you could do something like if (aggConfig.isFilterable()), and we don't need to ducktype this here.

Copy link
Contributor

Choose a reason for hiding this comment

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

@lukasolson lemme know if you wanna take a crack at this, if so I'll hold off on giving it another look. Otherwise I'll do another review first thing tomorrow.

Copy link
Member Author

Choose a reason for hiding this comment

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

@Bargs Just fixed this. Feel free to take a look now. Thanks!

Copy link
Contributor

@Bargs Bargs left a comment

Choose a reason for hiding this comment

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

Looked to me like the previous test run passed but s3 upload failed.

LGTM! Great stuff

@lukasolson lukasolson merged commit 9509d9e into elastic:master May 9, 2017
lukasolson added a commit to lukasolson/kibana that referenced this pull request May 9, 2017
* Don't prevent filterable rows just because they don't have a field

* Don't allow filtering on unfilterable fields

* Move isFilterable to aggConfig
@lukasolson
Copy link
Member Author

Backported to 5.x (5.5.0) in f25f118.

snide pushed a commit to snide/kibana that referenced this pull request May 30, 2017
* Don't prevent filterable rows just because they don't have a field

* Don't allow filtering on unfilterable fields

* Move isFilterable to aggConfig
@lukasolson lukasolson deleted the data-table-filters branch March 27, 2018 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Filters Feature:Visualizations Generic visualization features (in case no more specific feature label is available) release_note:fix review v5.5.0 v6.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants