nwogu/laravel-searchman 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nwogu/laravel-searchman

Composer 安装命令:

composer require nwogu/laravel-searchman

包简介

MySql Driver for Laravel Scout

README 文档

README

MySql Driver for Laravel Scout

Requirements

  • Requires Laravel Installed ^5.6
  • Requires Laravel Scout ^7.0

Installation

composer require nwogu\laravel-searchman

Setup

Searchman Provides a Mysql Driver for Laravel Scout, for full text search
with indexing priorities and sql where expressions.

Laravel Scout Documentation

After installing Searchman, you can publish the configuration
using the vendor:publish Artisan command. This command will publish the searchman.php
configuration file to your config directory:

php artisan vendor:publish --provider="Nwogu\SearchMan\Provider\SearchableServiceProvider"

Add the Nwogu\SearchMan\Traits\SearchMan trait to the model you would like to make searchable. This trait uses Laravel's Scout Searchable and adds extra methods required by the engine:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Nwogu\SearchMan\Traits\SearchMan;

class Meeting extends Model
{
    use SearchMan;
}

As with Scout, you can overide the searchableAs method in your model to change
the default index table name.

Queuing

As at v1.0.1, Searchman has not been effectively tested with queues.

Migrations

Run the command php artisan searchman:make-index {Model} to generate the index
for the specific model.

php artisan searchman:make-index "App\Meeting"

A migration file will be created in laravel's default base migrations folder.

run the migration with php artisan migrate to publish the migration.

At the point, you can now start indexing your models.

Laravel Scout Documentation

Priority Handlers

Searchman is built around indexing priorities. By default, two priority handlers
are available for use

  • Nwogu\SearchMan\PriorityHandlers\LocationPriorityHandler
  • Nwogu\SearchMan\PriorityHandlers\LongTextPriorityHandler

You can specify which handler to use for your indexing by defining the method
getIndexablePriorities on your indexable model. It should return an array
specifing the column name and the handler.

    public function getIndexablePriorities()
    {
        return [
            'minutes' => LongTextPriorityHandler::class,
            'email' => LocationPriorityHandler::class
        ];
    }

By default, the LocationPriorityHandler is used for all indexing. you can
overide this in the searchman config file.
Building your own handlers is easy. Implement the Priority handler Interface and you are good to go.

Searching

Laravel Scout only suports strict where clauses. but with Searchman, you can specify the operation of
your where statements using :.

App\Meeting::search("discussion on health")->where("attendance:>", 10)->get();

For more on search, look up the Laravel Scout Documentation

Results

Calling get on your query would return an Eloquent collection of models sorted by the priority attribute.

    {#3017
        +"id": 9,
        +"society_id": 1,
        +"name": "General Meeting Thursday, 21 Mar, 2019",
        +"type": "general meeting",
        +"minute": "<p>tjlkj;km;</p>",
        +"start_time": "2019-03-18 14:00:00",
        +"end_time": "2019-03-18 17:00:00",
        +"presider": 1,
        +"total_attendance": 1,
        +"created_at": "2019-03-18 19:16:01",
        +"updated_at": "2019-03-18 19:16:01",
        +"meeting_date": "2019-03-21 20:19:00",
        +"priority": 3.0,
        +"document_id": 9,
        +"priotity": 7.5
    }

nwogu/laravel-searchman 适用场景与选型建议

nwogu/laravel-searchman 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 24 次下载、GitHub Stars 达 26, 最近一次更新时间为 2019 年 05 月 15 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「mysql」 「laravel」 「indexing」 「scout」 「priorities」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 nwogu/laravel-searchman 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 nwogu/laravel-searchman 我们能提供哪些服务?
定制开发 / 二次开发

基于 nwogu/laravel-searchman 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 24
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 26
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 26
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-05-15