elasticsearch,Php,Laravel,elasticsearch" /> elasticsearch,Php,Laravel,elasticsearch" />

Php ElasticSearch 6.2-aggs返回:未知\命名\对象\异常

Php ElasticSearch 6.2-aggs返回:未知\命名\对象\异常,php,laravel,elasticsearch,Php,Laravel,elasticsearch,当我将此参数传递到$elastic->search($params2)时 它给了我这个例外 {“error”:{“root_cause”:[{“type”:“unknown_named_object_exception”,“reason”:“unknown_named_object_exception”,“line”:“unknown BaseAggregationBuilder[0]”,“line”:“col”:117},“status”:400} 我使用的是ErickTamayo/larav

当我将此参数传递到$elastic->search($params2)时

它给了我这个例外

{“error”:{“root_cause”:[{“type”:“unknown_named_object_exception”,“reason”:“unknown_named_object_exception”,“line”:“unknown BaseAggregationBuilder[0]”,“line”:“col”:117},“status”:400}


我使用的是ErickTamayo/laravel scout弹性套装

您需要删除
术语
热门歌曲

$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]]
                                ]
                            ]
                        ]
                    ]
                ]
            ],
        ]
    ];

删除
[“terms”=>[“field”=>“type\u id”,“size”=>4],
=>“terms”=>[“field”=>“type\u id”,“size”=>4],谢谢,现在我有了新的异常{“error”:{“root\u cause”:[{“type”:“parsing\u exception”,“reason”:“聚合定义为[top开始于一个[START\u数组],[START\u对象],“line”:1,“col”:164}],“type”:“parsing_exception”,“reason”:“聚合定义为[top以[START_数组]开始,预期为[START_对象]。”,“line”:1,“col”:164},“status”:400}是的,谢谢我已经更改了它并有了新的异常谢谢,现在我有了新的异常{“error”:{“root_cause”:[{“type”:“parsing_exception”,“reason”:“聚合定义为[top以[START_数组]开头,应为[START_对象]。”,“行”:1,“列”:164}],“类型”:“解析_异常”,“原因”:“聚合定义为[top以[START_数组]开头,应为[START_对象]。”,“行”:1,“列”:164},“状态”:400}您复制/粘贴了我的答案吗?
$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]
                                ]
                            ]
                        ]
                    ]
                ]
            ],
        ]
    ];