mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-05 13:40:39 +08:00
OR support added with contains
This commit is contained in:
parent
6eb9389e81
commit
5894acdb2d
@ -23,6 +23,7 @@ var operatorMapping = map[string]string{
|
||||
|
||||
const (
|
||||
AND = "and"
|
||||
OR = "or"
|
||||
ORDER = "order"
|
||||
ORDER_BY = "orderBy"
|
||||
TIMESTAMP_START = "timestampStart"
|
||||
@ -168,7 +169,7 @@ func parseLogQuery(query string) ([]string, error) {
|
||||
|
||||
operatorRemovedTokens := strings.Split(operatorRegex.ReplaceAllString(v, " "), " ")
|
||||
searchCol := strings.ToLower(operatorRemovedTokens[0])
|
||||
if searchCol == AND {
|
||||
if searchCol == AND || searchCol == OR {
|
||||
searchCol = strings.ToLower(operatorRemovedTokens[1])
|
||||
}
|
||||
col := searchCol
|
||||
@ -179,6 +180,8 @@ func parseLogQuery(query string) ([]string, error) {
|
||||
f := fmt.Sprintf(`%s %s '%%%s%%' `, col, operatorMapping[opLower], searchString[1:len(searchString)-1])
|
||||
if strings.HasPrefix(strings.ToLower(v), AND) {
|
||||
f = "AND " + f
|
||||
} else if strings.HasPrefix(strings.ToLower(v), OR) {
|
||||
f = "OR " + f
|
||||
}
|
||||
sqlQueryTokens = append(sqlQueryTokens, f)
|
||||
} else {
|
||||
|
@ -37,6 +37,11 @@ var correctQueriesTest = []struct {
|
||||
`resource contains 'Hello, "World"' and myresource contains 'abcd'`,
|
||||
[]string{`resource ILIKE '%Hello, "World"%' `, `AND myresource ILIKE '%abcd%' `},
|
||||
},
|
||||
{
|
||||
"contains with or",
|
||||
`id in ('2CkBCauK8m3nkyKR19YhCw6WbdY') or fulltext contains 'OPTIONS /api/v1/logs'`,
|
||||
[]string{`id IN ('2CkBCauK8m3nkyKR19YhCw6WbdY') `, `OR body ILIKE '%OPTIONS /api/v1/logs%' `},
|
||||
},
|
||||
{
|
||||
`filters with lt,gt,lte,gte operators`,
|
||||
`id lt 100 and id gt 50 and code lte 500 and code gte 400`,
|
||||
|
Loading…
x
Reference in New Issue
Block a user