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.
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.
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 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 nwogu/laravel-searchman 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Dibi is Database Abstraction Library for PHP
Laravel and Lumen ElasticSearch query builder to build complex queries using an elegant syntax
A SilverStripe module to optimise the Meta, crawling, indexing, and sharing of your website content (forked from Cyber-Duck/Silverstripe-SEO)
Laravel, Lumen and Native php elasticseach query builder to build complex queries using an elegant syntax
Laravel, Lumen and Native php elasticseach query builder to build complex queries using an elegant syntax
PHP module for MySql database
统计信息
- 总下载量: 24
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 26
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-05-15