我是Elasticsearch的初学者,今天我在制作“多AND OR”查询时遇到了问题。 我有一个我需要在Elastic中转换的SQL查询:
WHERE host_id = 999 AND psh_pid = 444 AND psh_ppid = 777
OR host_id = 111 AND psh_pid = 666 AND psh_ppid = 333
OR ..... (indefinitely)
我被迫通过几次查询来做这件事吗?
答案 0 :(得分:1)
我很抱歉,但我认为我自己找到了解决方案:3
如果有人需要这个,我把它放在这里!
{"from":0,
"size":100,
"query":
{"bool":
{"should":
[{"bool":
{"must":
[{"query_string":
{"query":"801","fields":["host_id"]}},
{"query_string":
{"query":"1","fields":["psh_pid"]}},
{"query_string":
{"query":"0","fields":["psh_ppid"]}}
]}
},{"bool":
{"must":
[{"query_string":
{"query":"801","fields":["host_id"]}},
{"query_string":
{"query":"2621550","fields":["psh_pid"]}},
{"query_string":
{"query":"1","fields":["psh_ppid"]}}
]
}}
]
}
}
}