-
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
[Transform] Support for the top_metrics
aggregation
#101152
[Transform] Support for the top_metrics
aggregation
#101152
Conversation
Pinging @elastic/ml-ui (:ml) |
|
||
describe('isSpecialSortField', () => { | ||
test('detects special sort field', () => { | ||
expect(isSpecialSortField('_score')).toBe(true); |
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.
nit: would be good to add one or more test cases here to assert they will return false
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.
Done in a2ae489
|
||
const sortDirectionOptions = Object.values(SORT_DIRECTION).map((v) => ({ | ||
id: v, | ||
label: v, |
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.
Should the labels in these options be internationalized? 🤔
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 don't recall seeing asc
and desc
to be translated in Kibana 🤔
> | ||
<EuiSelect | ||
options={NUMERIC_TYPES_OPTIONS[sortFieldType as KbnNumericType].map((v) => ({ | ||
text: v, |
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.
Like the options above, should these be internationalized?
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 believe we should not translate type names
sortDirection = sortDefinition; | ||
} | ||
|
||
if (typeof sortDefinition === 'object') { |
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.
nit: I think we can use isPopulatedObject here
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.
Updated in 24b7c6f
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.
Left one small remark. UI text LGTM, thanks!
..._transform/components/step_define/common/top_metrics_agg/components/top_metrics_agg_form.tsx
Outdated
Show resolved
Hide resolved
thanks for testing it @qn895! 🙏 I improved the validation so it shouldn't allow applying invalid changes. |
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.
Added a comment, but generally code LGTM
label: v, | ||
})); | ||
|
||
const sortFieldType = fields.find((f) => f.name === aggConfig.sortField)?.type; |
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.
should sortFieldOptions
, sortDirectionOptions
, sortModeOptions
and sortFieldType
all be wrapped in some useMemo
?
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.
Sorry, merged the PR from my phone and missed this comment. Definitely no harm in useMemo
, but I don't expect any performance issues with the current code even with thousands of fields available. Also, this component is only rendered with the popover form is visible.
💚 Build Succeeded
Metrics [docs]Module Count
Async chunks
History
To update your PR or re-run it, just comment with: cc @darnautov |
* [ML] init top_metrics agg * [ML] support sort * [ML] support _score sorting * [ML] support sort mode * [ML] support numeric type sorting * [ML] update field label, hide additional sorting controls * [ML] preserve advanced config * [ML] update agg fields after runtime fields edit * [ML] fix TS issue with EuiButtonGroup * [ML] fix Field label * [ML] refactor setUiConfig * [ML] update unit tests * [ML] wrap advanced sorting settings with accordion * [ML] config validation with tests * [ML] fix preserving of the unsupported config * [ML] update translation message * [ML] fix level of the custom config * [ML] preserve unsupported config for sorting
💚 Backport successful
This backport PR will be merged automatically after passing CI. |
) * [ML] init top_metrics agg * [ML] support sort * [ML] support _score sorting * [ML] support sort mode * [ML] support numeric type sorting * [ML] update field label, hide additional sorting controls * [ML] preserve advanced config * [ML] update agg fields after runtime fields edit * [ML] fix TS issue with EuiButtonGroup * [ML] fix Field label * [ML] refactor setUiConfig * [ML] update unit tests * [ML] wrap advanced sorting settings with accordion * [ML] config validation with tests * [ML] fix preserving of the unsupported config * [ML] update translation message * [ML] fix level of the custom config * [ML] preserve unsupported config for sorting Co-authored-by: Dima Arnautov <[email protected]>
Summary
Resolves #98127
Adds UI support for the
top_metrics
aggregation.Related Elasticsearch PR.
Checklist