java怎么搜索优化_如何优化弹性搜索查询

在过去的几个月里,我一直在阅读弹性搜索文档,并继续优化我的查询,但我似乎无法获得低于500-600毫秒的搜索查询 . 在本地数据较少的情况下,我可以在~80-200ms内获得响应 .

概述我要完成的任务:

我在Laravel中有12种不同的型号可以从一个搜索栏中搜索到 . 作为某人的类型,它会被搜索并返回到结果列表中 .

目前,我有这个搜索查询 . 有没有提及我如何改进这个?我查看了multi_match,但是我遇到了部分匹配问题并指定了所有字段 .

$results = $this->elastic->search([

'index' => config('scout.elasticsearch.index'),

'type' => $type ?? implode(',', array_keys($this->permissions, true, true)),

'body' => [

'query' => [

'bool' => [

'must' => [

[

'query_string' => [

'query' => "$searchQuery*",

],

],

],

'filter' => [

[

'term' => [

'account_id' => $accountId,

],

],

],

'should' => [

[

'term' => [

'_type' => [

'value' => 'customers',

'boost' => 1.3,

],

],

],

[

'term' => [

'_type' => [

'value' => 'contacts',

'boost' => 1.3,

],

],

],

[

'term' => [

'_type' => [

'value' => 'users',

'boost' => 1.3,

],

],

],

[

'term' => [

'_type' => [

'value' => 'chart_accounts',

'boost' => 1.2,

],

],

],

],

],

],

'from' => $from,

'size' => $size,

],

]);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值