-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Conditionally show Visualize button based on aggregatable status #8694
Conversation
Two points of note...
I don't really know what this error means. How does it relate to the idea of a field being aggregatable?
How does this warning relate to the idea of a field being aggregatable, if at all? |
@@ -44,6 +44,7 @@ <h5 ng-show="!field.details.error">Quick Count <kbn-info info="Top 5 values base | |||
|
|||
<a | |||
ng-href="{{vizLocation(field)}}" | |||
ng-if="field.aggregatable" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be more ergonomic if it called a method, like this:
ng-if="isFieldVisualizable(field)"
which then called a service:
import isFieldVisualizable from 'ui/visualize/is_field_visualizable'; // location tbd
scope.isFieldVisualizable = isFieldVisualizable;
which codified this rule (and future related rules):
// is_field_visualizable.js
export default isFieldVisualizable(field) {
// Some explanation here about why non-aggregatable fields can't be visualized.
if (!field.aggregatable) {
return false;
}
return true;
}
It seems like a lot of code for such a small feature, but I think it's important we codify our business logic this way. Otherwise the "what" of the code isn't justified by a "why". Other benefits include increased readability, testability (we can test the service), and scalability (we can add additional rules to the service).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would agree if there were multiple factors that went into deciding if a field was "visualizable", but as things stand today I think that's a premature abstraction. Non-aggregatable fields can't be visualized because Kibana visualizes aggregations. I could add an inline comment which I think would be less confusing than creating a new service.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense. How about a compromise? Can you just put the isFieldVisualizable
method on the scope instead of in a separate service? At least this way the code becomes self-documenting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added an additional flag to the field object itself, I think it's a more appropriate place to put that kind of logic. Let me know how that looks to you.
The code works great! I just had a couple questions for my own enlightenment, and a couple small suggestions. |
Analyzed fields can only be aggregated if they have fielddata enabled. Pre-5.0 it was enabled by default, now it's disabled by default so that these errors are much more common.
If a user manually enables fielddata on an analyzed field they can still create visualizations with it, but it'll probably suck up a lot of memory and give unexpected results because you're visualizing the analyzed data, not the data as it originally existed in _source. So this warning is still relevant in those cases. |
@tbragin yup I see that too, and confirmed it only happens in this PR. Great catch |
…utton and remove it upon toggle
0254818
to
75a2f23
Compare
@tbragin fixed the whack-a-button problem. Ready for another look. |
LGTM |
@jbudz weird. That appears to be an existing issue in master as well. I'll see if I can fix it though. |
If you want a separate issue for it, this LGTM |
--------- **Commit 1:** Conditionally show Visualize button based on aggregatable status * Original sha: 76c2687 * Authored by Matthew Bargar <[email protected]> on 2016-10-14T22:23:37Z **Commit 2:** Switch to ng-show so controller can maintain reference to Visualize button and remove it upon toggle * Original sha: 9da6ddf * Authored by Matthew Bargar <[email protected]> on 2016-10-17T17:21:11Z **Commit 3:** Add visualizable flag to field object * Original sha: 75a2f23 * Authored by Matthew Bargar <[email protected]> on 2016-10-17T17:39:13Z
--------- **Commit 1:** Conditionally show Visualize button based on aggregatable status * Original sha: 76c2687 * Authored by Matthew Bargar <[email protected]> on 2016-10-14T22:23:37Z **Commit 2:** Switch to ng-show so controller can maintain reference to Visualize button and remove it upon toggle * Original sha: 9da6ddf * Authored by Matthew Bargar <[email protected]> on 2016-10-17T17:21:11Z **Commit 3:** Add visualizable flag to field object * Original sha: 75a2f23 * Authored by Matthew Bargar <[email protected]> on 2016-10-17T17:39:13Z
--------- **Commit 1:** Conditionally show Visualize button based on aggregatable status * Original sha: 77294135d9bc8c70f562a866ea1f52b83b56c1a2 [formerly 76c2687] * Authored by Matthew Bargar <[email protected]> on 2016-10-14T22:23:37Z **Commit 2:** Switch to ng-show so controller can maintain reference to Visualize button and remove it upon toggle * Original sha: 414865ec12af65652e9339329e6826270a3f4f0e [formerly 9da6ddf] * Authored by Matthew Bargar <[email protected]> on 2016-10-17T17:21:11Z **Commit 3:** Add visualizable flag to field object * Original sha: 8d830f2d92fbf099de573a60ce878a9a3ef3ccea [formerly 75a2f23] * Authored by Matthew Bargar <[email protected]> on 2016-10-17T17:39:13Z Former-commit-id: 6874f1b
[backport] PR elastic#8694 to 5.x Former-commit-id: 325d2ec
Now that we know which fields are aggregatable, we should only show the Visualize button in the Discover sidebar when a field is in fact aggregatable.
Fixes #5873