lib/logstorage: allow using - instead of ! in front of (...)

This commit is contained in:
Aliaksandr Valialkin 2024-09-29 11:12:22 +02:00
parent fce6fc745a
commit b7a3d575da
No known key found for this signature in database
GPG key ID: 52C003EE2BCDB9EB
2 changed files with 3 additions and 1 deletions

View file

@ -840,7 +840,7 @@ func parseGenericFilter(lex *lexer, fieldName string) (filter, error) {
}
return f, nil
case lex.isKeyword("("):
if !lex.isSkippedSpace && !lex.isPrevToken("", ":", "(", "!", "not") {
if !lex.isSkippedSpace && !lex.isPrevToken("", ":", "(", "!", "-", "not") {
return nil, fmt.Errorf("missing whitespace before the search word %q", lex.prevToken)
}
return parseParensFilter(lex, fieldName)

View file

@ -646,6 +646,8 @@ func TestParseQuerySuccess(t *testing.T) {
f(`not(foo)`, `!foo`)
f(`not (foo)`, `!foo`)
f(`not ( foo or bar )`, `!(foo or bar)`)
f(`!(foo or bar)`, `!(foo or bar)`)
f(`-(foo or bar)`, `!(foo or bar)`)
f(`foo:!""`, `!foo:""`)
f("_msg:foo", "foo")
f("'foo:bar'", `"foo:bar"`)