身安不如心安,屋宽不如心宽 。

es查询条件编写

匿名 | 发布于2018年09月05日 | 阅读数:3318

where (status = 0) || (status = 1 && id = 0) 这种条件 es怎么编写
已邀请:

God_lockin

赞同来自:

用should构建啊
 should:[
{
status:0
},
{
status:1, id:0
}
]
 
 

elasticStack - 90后it大数据男

赞同来自:

{
"query": {
"bool": {
"should":[
{
"term":{
"status":{
"value":1
}
}
},
{
"bool": {
"must": [
{
"term": {
"status": {
"value": 0
}
}
},
{
"term": {
"id": {
"value": 1
}
}
}
]
}
}
],
"minimum_should_match": 1
}
}
}

要回复问题请先登录注册