我是ElasticSearch的新手,我正在尝试查询嵌套文档的多个字段。它实际上只有在完全匹配时才会成功。
return Record::search()
->multiMatch([
'original_name',
'some_id',
'contributors.name',
'customNames.custom_name',
], ' * '.$searchTerm.' * ', ['fuzziness' => 'AUTO'])
->size(500)->get()->hits();
有什么想法吗?
SQL等价物是:
SELECT * FROM WHERE records LIKE '%'.$seachTerm.'%'
(加上一些额外的联接)
答案 0 :(得分:0)
$query = [
'multi_match' => [
'query' => $searchTerm,
'fields' => [
'original_name',
'some_id'
]
],
];
$records = Record::searchByQuery($query, '', '', $count, $offset, [
'id' => ['order' => 'desc']
]);