php artisan make:search-rule MySearchRule
<?php namespace App; use ScoutElastic\SearchRule; class MySearchRule extends SearchRule { /** * @inheritdoc */ public function buildHighlightPayload() { // } /** * @inheritdoc */ public function buildQueryPayload() { return [ ‘must‘ => [ ‘query_string‘ => [ ‘query‘ => $this->builder->query, ‘fields‘ => ["sell_point^10", "name^5", "title_tags^5", "cate_tags^3", "category_name^8", "share_intro", "reason"], ‘type‘ => "most_fields" ] ], ]; } }
protected $searchRules = [ MySearchRule::class ];
原文:https://www.cnblogs.com/mmmzh/p/14684322.html