gpt4 book ai didi

elasticsearch - 如何在 elasticsearch 中组合多个 bool 查询

转载 作者:行者123 更新时间:2023-11-29 02:45:04 25 4
gpt4 key购买 nike

我想创建以下查询的等价物 -

(city = 'New York' AND state = 'NY') AND ((businessName='Java' and businessName='Shop') OR (category='Java' and category = 'Shop'))

我使用 must 和 should 尝试了 bool 查询的不同组合,但似乎没有任何效果。这能做到吗?

最佳答案

这样的事情怎么样:

{
"query": {
"match_all": {}
},
"filter": {
"bool": {
"must": [
{
"term": {
"city": "New york"
}
},
{
"term": {
"state": "NY"
}
},
{
"bool": {
"should": [
{
"bool": {
"must": [
{
"term": {
"businessName": "Java"
}
},
{
"term": {
"businessName": "Shop"
}
}
]
}
},
{
"bool": {
"must": [
{
"term": {
"category": "Java"
}
},
{
"term": {
"category": "Shop"
}
}
]
}
}
]
}
}
]
}
}
}

关于elasticsearch - 如何在 elasticsearch 中组合多个 bool 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36389513/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com