【发布时间】:2016-06-13 13:05:30
【问题描述】:
我正在尝试构造必须查询多个词的数组,如下所示:
$params = [
'body' => [
'query' => [
"bool" => [
"must" => [
"terms" => [
"categories" => [
"Seating",
],
],
"terms" => [
"attributes.Color" => [
"Black",
],
]
],
"filter" => [
"range" => [
"price" => [
"gte" => 39,
"lte" => 2999,
],
],
],
],
],
'from' => 0,
'size' => 3,
],
];
在 JSON 中表示如下:
{
"query": {
"bool": {
"must": {
"terms": {
"attributes.Color": ["Black"]
}
},
"filter": {
"range": {
"price": {
"gte": "39",
"lte": "2999"
}
}
}
}
},
"from": 0,
"size": 3
}
问题是,JSON 对象在 PHP 中表示为数组,所以如果我为一个数组设置键,它就会被重写。你知道如何在 PHP 中创建多个词条查询吗?
提前致谢。
【问题讨论】:
-
为什么不对相同的键值进行分组?像这样 "terms" => [ "categories" => [ "Seating" ], "attributes.Color" => [ "Black" ] ],
标签: php elasticsearch querydsl