[英]Elasticsearch multiple fields OR query
这是我存储在ES中的示例记录:
"taskCurateStatus": true,
"taskMigrateStatus": true,
"verifiedFields": 7,
"taskId": "abcdef123",
"operatorEmail": "test@test.com"
Example Query I'm making via /_search:
{
"sort": [
{
"@timestamp": {
"order": "desc"
}
}
],
"query": {
"bool": {
"must": [
{
"match": {
"msg.operator_email": "test@test.com"
}
}
{
"range": {
"@timestamp": {
"gte": "2017-03-05",
"lte": "2017-03-12"
}
}
}
]
}
},
"from": 0,
"size": 50
}
基本上,我还希望按具有taskCurateStatus
或taskMigrateStatus
为true的文档进行过滤。 一些消息仅定义了其中之一。 我在考虑使用should
查询,但不确定如何将其与match
查询一起使用。 任何帮助,将不胜感激。 谢谢
您可以在must过滤器内添加另一个布尔过滤器。 这个布尔过滤器可以实现should子句,您可以在其中将布尔标志与应该合并两个布尔检查过滤器的应当过滤器进行比较
{
"sort": [{
"@timestamp": {
"order": "desc"
}
}],
"query": {
"bool": {
"must": [{
"match": {
"msg.operator_email": "test@test.com"
}
}, {
"range": {
"@timestamp": {
"gte": "2017-03-05",
"lte": "2017-03-12"
}
}
}, {
"bool": {
"should": [{
"term": {
"taskCurateStatus": {
"value": true
}
}
}, {
"term": {
"taskMigrateStatus": {
"value": true
}
}
}]
}
}]
}
},
"from": 0,
"size": 50
}
看一下上面的查询,看看是否有帮助谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.