Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/ui/public/agg_types/param_types/field.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ export function FieldParamTypeProvider(Private, $filter) {

const validField = this.getFieldOptions(aggConfig).byName[fieldName];
if (!validField) {
notifier.error(`Saved "field" parameter is now invalid. Please select a new field.`);
// check to see if a .raw field exists and use it if it does
const validRawField = this.getFieldOptions(aggConfig).byName[`${fieldName}.raw`];

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.

This won't work for newer fields using the .keyword convention. More generally, these names are just a convention, users can name their keyword multi fields anything they want. It would be nice if we interrogated the mappings and actually detected when a multi field exists instead of relying on names. Of course, that would blow this tiny change up into big change. We've needed knowledge about multi fields for a long time though :) At the very least, we should check for .keyword in addition to .raw.

if (validRawField) {
return validRawField;

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.

I think we should probably display an "info" notification when we change the field, so the user is aware of what's going on. It's possible they're intentionally trying to aggregate on a text field and just forgot to turn field data on, so without a notification that the field changed they may never realize they're not getting what they want.

}
notifier.error(`Field "${fieldName}" is not aggregatable. Please replace it with a keyword version of the field.`);
}

return validField;
Expand Down