Elasticsearch must_not查询与regex不匹配 [英] Elasticsearch must_not query doesn't match regex
本文介绍了Elasticsearch must_not查询与regex不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想过滤出所有在太多连接
存在于LogMessage字段中的文档。
我写的是:
'
{
query:{
bool :{
must:{
match:{
logType:Error
}
},
must_not: {
match:{
LogMessage:。*太多连接。*
}
}
}
} $ b另一方面,如果我在 >
我已经在这里验证了我的正则表达式:
https://regex101.com/r/EexTmV/1
请帮我解决这个问题。
解决方案您需要使用 regexp
查询而不是匹配
查询
:{
bool:{
must:{
match:{
logType:Error
}
},
must_not:{
regexp:{
LogMessage:。*太多连接。*
}
}
}
}
}
I want to filter out all documents where Too many connections
are present in LogMessage field.
The query I wrote is:
'
{
"query": {
"bool": {
"must": {
"match": {
"logType": "Error"
}
},
"must_not": {
"match": {
"LogMessage": ".*Too many connections.*"
}
}
}
}
}'
On the other hand, if I am using my whole string in LogMessage
field, it's working fine.
I have verified my regex here:
https://regex101.com/r/EexTmV/1
Please help me to solve this.
解决方案 You need to use a regexp
query instead of a match
query
{
"query": {
"bool": {
"must": {
"match": {
"logType": "Error"
}
},
"must_not": {
"regexp": {
"LogMessage": ".*Too many connections.*"
}
}
}
}
}
这篇关于Elasticsearch must_not查询与regex不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文