类似于 SQL = is_on_sale AND ( (price >20 AND cat_id iN(1,2)) OR (price >30 AND cat_id iN(3,4)) )
ES里面用这个类似查询相同效果
{
"filters": [
{
"type":"pairs",
"operators":[
{"name":"a3","operator":"must"},
{"name":"a4","operator":"must"}
]
},
{
"type": "",
"field": "is_on_sale",
"values":[1],
"pair": "a4",
"operator": "must"
},
{
"type":"pairs",
"operators":[
{"name":"a1","operator":"should"},
{"name":"a2","operator":"should"}
]
},
{
"type": "range",
"field": "price",
"values":[4.99,"*"],
"pair": "a1",
"operator": "must"
},
{
"type": "",
"field": "cat_id",
"values": [1, 2],
"pair": "a1",
"operator": "must"
},
{
"type": "range",
"field": "price",
"values":[0,"*"],
"pair": "a2",
"operator": "must"
},
{
"type": "",
"field": "cat_id",
"values": [3, 4],
"pair": "a2",
"operator": "must"
}
]
}