bottom
bottom copied to clipboard
Search filter improvement: not operator, better parsing
Checklist
- [x] I've looked through the documentation and existing open issues for similar feature requests.
Describe the feature request
I wanted to run a search query "user != root" or "state != sleeping" but apparently "!=" or "!" operators aren't supported. Digging into the code to find where to add, I found more improvements are possible.
Better Filter syntax
The search can be made in 3 modes
- Literal mode: activated when user types a plain string without operators or quoted string ( with escapes )
Action: whatever is typed is matched against
Name. Equivalent to double-quoting the text. - Regex mode: activated when Regex(Alt+W) is set, OR when user wraps the query in
/query/. Latter can support flags likeitoo. Action: whatever is typed is parsed as regex and matched againstName. - Query mode: activated when Regex(Alt+W) is unset and user types an operator.
Action: Executes query as a boolean expression, where:
- Value can be literal (
"quoted",'quoted'or numbers ), regexp: (/value/) or more shorthands for time, bytes, percentages, etc. - operators
!=(not equal),!(not),~(partial match) and current ones are supported. We can also support more operators likeinorlikeoperators from sql, but having regexp is enough I guess.
- Value can be literal (
Looking for feedback on the design before I try an implementation. I think this will improve the parser too, making it a proper expression parser.