php调用未定义的方法app,php - 在scout:import上调用未定义的方法App \\ Service :: makeAllSearchable() - 堆栈内存溢出...

我遇到BadMethodCallException的问题:尽管我具有Searchable(ScoutElastic \\ Searchable)特征,但调用未定义的方法App \\ Service :: makeAllSearchable()。

我正在使用laravel 5.8和elasticsearch 6.8.1,也正在使用babenkoivan / scout-elasticsearch-driver。 我有2个要搜索的模型。 1. Doctor.php和2. Service.php当我运行命令php artisan scout:import "App\\Doctor"它工作正常,但是php artisan scout:import "App\\Service"抛出错误。 对于Doctor and Service模型,我有以下文件

Service.php-ServiceIndexConfigurator.php-ServiceSearchRule.php

Doctor.php --- DoctorIndexConfigurator.php-DoctorSearchRule.php

FYI医生代码几乎相同。 这是Service.php

namespace App;

use ScoutElastic\Searchable;

use Illuminate\Database\Eloquent\Model;

class Service extends Model

{

use Searchable;

/**

* @var string

*/

protected $indexConfigurator = ServiceIndexConfigurator::class;

/**

* @var array

*/

protected $searchRules = [

ServiceSearchRule::class

];

/**

* @var array

*/

protected $mapping = [

'properties' => [

'service_name' => [

'type' => 'text'

],

'description' => [

'type' => 'text'

]

]

];

public function toSearchableArray()

{

return $this->only('service_name', 'description');

}

public function user()

{

return $this->belongsTo(User::class);

}

}

ServiceIndexConfigurator.php

namespace App;

use ScoutElastic\IndexConfigurator;

use ScoutElastic\Migratable;

class ServiceIndexConfigurator extends IndexConfigurator

{

use Migratable;

/**

* @var array

*/

protected $name = 'service_index';

protected $settings = [

'analysis' => [

'analyzer' => [

'es_std' => [

'type' => 'standard',

'stopwords' => '_english_'

]

]

]

];

}

ServiceSearchRule.php

namespace App;

use ScoutElastic\SearchRule;

class ServiceSearchRule extends SearchRule

{

/**

* @inheritdoc

*/

public function buildHighlightPayload()

{

//

}

/**

* @inheritdoc

*/

public function buildQueryPayload()

{

$query = $this->builder->query;

return [

'should' => [

[

'match' => [

'service_name' => [

'query' => $query,

'boost' => 1

]

]

],

[

'match' => [

'country' => [

'query' => $query,

'boost' => 2

]

]

],

[

'match' => [

'description' => [

'query' => $query,

'boost' => 3

]

]

],

[

'match' => [

'approx_cost' => [

'query' => $query,

'boost' => 4

]

]

],

[

'match' => [

'currency' => [

'query' => $query,

'boost' => 5

]

]

]

]

];

}

}

错误信息

BadMethodCallException : Call to undefined method App\Service::makeAllSearchable()

at /var/www/html/medicoocean.test/vendor/laravel/framework/src/Illuminate/Support/Traits/ForwardsCalls.php:50

46| * @throws \BadMethodCallException

47| */

48| protected static function throwBadMethodCallException($method)

49| {

> 50| throw new BadMethodCallException(sprintf(

51| 'Call to undefined method %s::%s()', static::class, $method

52| ));

53| }

54| }

Exception trace:

1 Illuminate\Database\Eloquent\Model::throwBadMethodCallException("makeAllSearchable")

/var/www/html/medicoocean.test/vendor/laravel/framework/src/Illuminate/Support/Traits/ForwardsCalls.php:36

2 Illuminate\Database\Eloquent\Model::forwardCallTo(Object(Illuminate\Database\Eloquent\Builder), "makeAllSearchable", [])

/var/www/html/medicoocean.test/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1614

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值