Skip to content

Conversation

luorenshu
Copy link

@luorenshu luorenshu commented Jun 15, 2022

配置 Elasticsearch 搜索设置

搜索设置可以通过在模型中添加 searchSetting 属性来配置,目前只支持高亮:

<?php

declare(strict_types=1);

namespace App\Models;

use Hyperf\Database\Model\Model;
use HyperfExt\Scout\Searchable;

class Post extends Model
{
    use Searchable;

      // 搜索 `searchSetting` 配置
      public $searchSetting = [
        //高亮
        'attributesToHighlight' => [
            'title' => ["pre_tags" => "<b style='color:red'>", "post_tags" => "</b>"],
            'content'
        ],
    ];
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant