-
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
[ML] Anomaly Explorer - ensure valid syntax after removing 2nd of 3 filters via icon #34187
[ML] Anomaly Explorer - ensure valid syntax after removing 2nd of 3 filters via icon #34187
Conversation
Pinging @elastic/ml-ui |
💚 Build Succeeded |
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.
@peteharverson - added a fix for the OR operator as well 👍 |
💚 Build Succeeded |
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.
LGTM
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.
LGTM
// If string has a double 'and' operator (e.g. tag:thing and and tag:other) remove as it is illegal kuery syntax | ||
const invalidAndPattern = /\s+(and)\s+(and)\s+/ig; | ||
// If string has a double 'or' operator (e.g. tag:thing or or tag:other) remove as it is illegal kuery syntax | ||
const invalidOrPattern = /\s+(or)\s+(or)\s+/ig; |
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.
this won't catch OR AND
or AND OR
.
the regex could be changed to something like /\s+(and|or)\s+(and|or)\s+/ig
to catch all combinations of duplicate operators.
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.
LGTM
💚 Build Succeeded |
…ilters via icon (elastic#34187) * Remove middle filter value correctly using icons * remove middle filter value in OR query correctly with icons * combine operator pattern check
Summary
Fix for #33861
When creating filters via filter icons in Anomaly Explorer - if middle filter is removed via icon duplicate
and
operators are left in the filter bar - which is invalid syntax.This PR adds a check for those duplicate operators when removing a filter via icons and removes the duplication. Resulting syntax is valid.
Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.- [ ] Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support- [ ] Documentation was added for features that require explanation or tutorialsFor maintainers
- [ ] This was checked for breaking API changes and was labeled appropriately- [ ] This includes a feature addition or change that requires a release note and was labeled appropriately