我想过滤掉 LogMessage 字段中存在 Too many connections
的所有文档。
我写的查询是:
'
{
"query": {
"bool": {
"must": {
"match": {
"logType": "Error"
}
},
"must_not": {
"match": {
"LogMessage": ".*Too many connections.*"
}
}
}
}
}'
另一方面,如果我在 LogMessage
字段中使用我的整个字符串,它工作正常。
我在这里验证了我的正则表达式:
https://regex101.com/r/EexTmV/1
请帮我解决这个问题。
最佳答案
您需要使用 regexp
query而不是 match
查询
{
"query": {
"bool": {
"must": {
"match": {
"logType": "Error"
}
},
"must_not": {
"regexp": {
"LogMessage": ".*Too many connections.*"
}
}
}
}
}
关于curl - Elasticsearch must_not 查询与正则表达式不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42524616/