Skip to content

changing the way aggconfig field filter works#22756

Merged
ppisljar merged 4 commits intoelastic:masterfrom
ppisljar:fix/aggParams
Sep 11, 2018
Merged

changing the way aggconfig field filter works#22756
ppisljar merged 4 commits intoelastic:masterfrom
ppisljar:fix/aggParams

Conversation

@ppisljar
Copy link
Copy Markdown
Contributor

@ppisljar ppisljar commented Sep 6, 2018

for #21827 we need to change the way we filter which fields aggregation supports.

currently the top hit aggregation would show all the fields on table or metric visualization and only number fields on other visualizations.

the filtering should not happen on aggconfigs level, as as far as aggregations are concerned top_hit can
work with every field type. We need to have additional level of filtering on the editor level however.

qa: nothing should change, top_hits should still show all fields with table or metric visualization and only number fields otherwise, just implementation is different.

Dev Docs

AggConfig field param

Every aggregation (AggConfig) with field parameter type needs to set the type to field now (as before setting the name to field was sufficient.)

We don't recommend writing your own aggregations. We don't consider this to be a public API, and it's very likely this will change in the future. Since we know a couple of plugins use this nevertheless, we are announcing this change here.

@ppisljar ppisljar requested review from markov00 and timroes September 6, 2018 11:06
initialSet: params.map(function (config) {
const type = config.name === 'field' ? config.name : config.type;
const Class = paramTypeMap[type] || paramTypeMap._default;
const Class = paramTypeMap[config.type] || paramTypeMap._default;
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.

setting param type is now obligatory (before we defaulted to field type if name was field)

return type === 'number';
};

aggTypeFieldFilters.addFilter(
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.

top_hit now adds a filter for the fields which will be used by editor

/**
* Get the options for this field from the indexPattern
*/
FieldParamType.prototype.getFieldOptions = function (aggConfig) {
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.

method was renamed to getAvailableFields

*/
FieldParamType.prototype.getAvailableFields = function (fields) {

return new IndexedArray({
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.

it filters all the fields down to the fields supported by this aggregation

indexPattern: IndexPattern,
aggConfig: AggConfig
) {
public filter(fields: any[], fieldParamType: FieldParamType, aggConfig: AggConfig, vis: Vis) {
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 filters are executed by editor now

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.

(so we can have access to vis object)

import 'angular-ui-select';
import { uiModules } from '../modules';
import { getFieldOptions } from './lib/filter_editor_utils';
import { getFilterableFields } from './lib/filter_editor_utils';
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 was renamed as the old name was used for multiple functions, where none of them got you the field options :)

@ppisljar ppisljar added review Feature:Visualizations Generic visualization features (in case no more specific feature label is available) v6.5.0 labels Sep 6, 2018
@markov00 markov00 added the release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. label Sep 6, 2018
@markov00
Copy link
Copy Markdown
Contributor

markov00 commented Sep 6, 2018

@ppisljar Please check this: https://l7xor5om2l.codesandbox.io/ to conform the dev docs to the "standard"

Copy link
Copy Markdown
Contributor

@markov00 markov00 left a comment

Choose a reason for hiding this comment

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

Code LGTM. Added some minor questions.

if (aggConfig.type.name !== 'top_hit' || vis.type.name === 'table' || vis.type.name === 'metric') {
return true;
}
return field.type === 'number';
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.

nit: because we have a isNumber function above, we can use it :)

}

return filterByType([field], filterFieldTypes).length !== 0;
}), ['type', 'name']),
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.

What if we first filter to an object and than sort by? it will be a bit more readable so you dont have to look 10 rows below to understand what is the sorting by params

@elasticmachine
Copy link
Copy Markdown
Contributor

💔 Build Failed

@elasticmachine
Copy link
Copy Markdown
Contributor

💔 Build Failed

@ppisljar
Copy link
Copy Markdown
Contributor Author

ppisljar commented Sep 7, 2018

retest

@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

@timroes
Copy link
Copy Markdown
Contributor

timroes commented Sep 9, 2018

@jen-huang could you please check that these changes will still work for roll-up support. We needed to change the existing implementation a bit for the pipeline refactoring.

@ppisljar ppisljar merged commit 6246c58 into elastic:master Sep 11, 2018
@elasticmachine
Copy link
Copy Markdown
Contributor

💔 Build Failed

@markov00 markov00 mentioned this pull request May 29, 2019
@markov00 markov00 mentioned this pull request Jun 7, 2019
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature:Visualizations Generic visualization features (in case no more specific feature label is available) release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. review v6.5.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants