弹性搜索以匹配顶级字段和嵌套字段

时间:2017-02-06 03:47:17

标签: elasticsearch

我似乎无法使此查询正常工作

我正在尝试匹配所有与$ channel_name匹配的标签, 还有一个视频,名称为$ search。

我认为嵌套部分搞砸了。我该如何修复此查询? enter image description here

$body = [
'query' =
    [
        "bool" => [
            "must" => [
                'match_phrase' => ['name' => $channel_name]

            ],
            'nested' => [
                'path' => 'videos',
                'query' => [
                    'bool' => [
                        [
                            'must' => [
                                'match' => [
                                    'videos.name' => $search
                                ]
                            ]
                        ]

                    ]

                ]
            ]
        ],

    ],
'inner_hits' => [
    'videos' => [
        'path' => [
            'videos' => [
                'size' => $this->pageSize,
                'sort' => $sortOrder,
                'from' => ($pageNumber - 1) * $this->pageSize,
                'query' => [
                    'match_all' => []
                ]
            ]
        ]
    ]

]

];

0 个答案:

没有答案