當我查詢Elasticsearch產品某一特定製造商,這個工程:與has_child PHP ElasticSearch複合查詢
$params = ['index' => 'products',
'type' => 'product',
'body' => ['query' =>
['match' => ['manufacturers_id' => $query],],
],
];
但是,當我也想在條件補充的是,產品自帶銀色的,這是我已經添加爲孩子記錄的產品記錄,我得到一個語法錯誤:
$params = ['index' => 'products',
'type' => 'product',
'body' => ['query' =>
['match' => ['manufacturers_id' => $query],],
['query' =>
['has_child' =>
['type' => 'attributes',
['query' =>
['color' => 'Silver'],],
],
],
],
],
];
的錯誤是
{
"error": {
"col": 49,
"line": 1,
"reason": "Unknown key for a START_OBJECT in [0].",
"root_cause": [
{
"col": 49,
"line": 1,
"reason": "Unknown key for a START_OBJECT in [0].",
"type": "parsing_exception"
}
],
"type": "parsing_exception"
},
"status": 400
}
也試過
$params = ['index' => 'products',
'type' => 'product',
'body' => ["query"=> [
"match"=> [
"manufacturers_id"=> [11]
],
"has_child"=> [
"type"=> "attributes",
"query"=> [
"match"=> [
"color"=> "silver"
],
],
],
],
],
];
我得到「在上一1:39 START_ARRAY無法獲取文本。」
獲取無法在1:39的START_ARRAY上獲取文本。 –