dongtan7418 2018-07-04 09:05
浏览 86

laravel scout searchable trait

I added the Laravel\Scout\Searchable trait to the model to make it searchable, this is my model

<?php
namespace App;
use Laravel\Scout\Searchable;
use Illuminate\Database\Eloquent\Model;

class Business extends Model
{
    use Searchable;
    protected $table = 'business';
    public function searchableAs()
    {
        return 'business_index';
    }
}

I'm using vue js with axios, when I'm posting a request via axios the request time become 2.76s~, but when i commented the use searchable like this

<?php
namespace App;
use Laravel\Scout\Searchable;
use Illuminate\Database\Eloquent\Model;

class Business extends Model
{
    //use Searchable;
    protected $table = 'business';
    public function searchableAs()
    {
        return 'business_index';
    }
}

the request time became 300ms~ only,

is there any way to make a request faster without compromising the use Searchable ?

  • 写回答

1条回答 默认 最新

  • dsc56927 2019-03-28 07:28
    关注

    You should set up queuing for Laravel Scout so it can process this in the background using Redis or something, which will stop your actual requests being slow.

    Enable Queueing on Scout: https://laravel.com/docs/5.8/scout#queueing

    config/scout.php configuration file to true:

    'queue' => true,
    

    Queue Setup: https://laravel.com/docs/5.8/queues

    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?