Kaz*_*uto 5 elasticsearch laravel laravel-5.1
我有两个模型:
每个帖子至少有 1 个类别,此关系通过包含帖子 ID 和类别 ID 的数据透视表显示。
我已经编写了代码来查询关键字,但我仍然想不出一种方法来在搜索中包含该类别。
在我的帖子模型中:
use ElasticquentTrait;
protected $mappingProperties = array(
'id' => [
'type' => 'integer',
],
'name' => [
'type' => 'string',
"analyzer" => "standard",
],
'description' => [
'type' => 'string',
"analyzer" => "standard",
],
'address' => [
'type' => 'string',
"analyzer" => "standard",
],
);
Run Code Online (Sandbox Code Playgroud)
这是搜索查询的代码:
$search_results = BusinessListing::searchByQuery([
'multi_match' => [
'query' => $search_term,
'fields' => [ "name^5", "description", "address"],
'fuzziness' => "AUTO"
],
]);
Run Code Online (Sandbox Code Playgroud)
我想到的一种解决方案是用 laravel 过滤掉结果并删除类别不匹配的结果,但我认为这不是最佳解决方案。
我正在使用elasticquent/elasticquent库。
帮助将不胜感激。非常感谢!
归档时间: |
|
查看次数: |
333 次 |
最近记录: |