[ "must" => [ 0 => [ "term" => [ -6ren">
gpt4 book ai didi

php - Elasticsearch多个术语/过滤器

转载 作者:行者123 更新时间:2023-12-02 22:27:46 24 4
gpt4 key购买 nike

我正在尝试根据多个条件进行过滤。如果我指定一个学期,我就能过滤

[
"bool" => [
"must" => [
0 => [
"term" => [
"interests" => [
"value" => "art"
]
]
]
]
]
]

但是当我使用多个术语时,我总是会得到一个空洞的回应。
[
"bool" => [
"must" => [
0 => [
"term" => [
"interests" => [
"value" => "art"
]
]
]
1 => [
"term" => [
"community_privacy" => [
"value" => "private"
]
]
]
]
]
]

我是否误解了我应该如何使用多个术语?

最佳答案

php语法对我来说是新的,但是在JSON中的数组中,您需要将每个term子句包装在其自己的boolmust / filter / etc中。因此,在JSON中将如下所示:

{"query":{
"bool":{
"must":[
{"bool":{
"must":{
"term":{
"interests" : "art"
}
}
}
},
{"bool":{
"must":{
"term":{
"community_privacy": "private"
}
}
}
}
]
}
}
}

关于php - Elasticsearch多个术语/过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57075457/

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