$params2 = [
'index' => 'index',
'type' => "items",
'body' => [
'aggs' => [
"types" => [
"filter" => [
"bool" => [
"should" => [
["term" => ["type_id" => 1]],
["term" => ["type_id" => 2]]
]
]
],
"aggs" => [
"types" =>[
["terms" => ["field" => "type_id","size" => 4]],
"aggs" =>[
"top" => [
["top_hits" => ["size" => 2]]
]
]
]
]
]
],
]
];
当我将此参数传递给$ elastic-> search($ params2)时;
它给我这个异常(exception)
我正在使用ErickTamayo / laravel-scout-elastic软件包
最佳答案
您需要删除terms
和top_hits
周围的方括号
$params2 = [
'index' => 'index',
'type' => "items",
'body' => [
'aggs' => [
"types" => [
"filter" => [
"bool" => [
"should" => [
["term" => ["type_id" => 1]],
["term" => ["type_id" => 2]]
]
]
],
"aggs" => [
"types" =>[
"terms" => ["field" => "type_id","size" => 4],
"aggs" =>[
"top" => [
"top_hits" => ["size" => 2]
]
]
]
]
]
],
]
];
关于php - ElasticSearch 6.2-aggs返回:unknown_named_object_exception,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/48881343/