Download the PHP package augustdai/hyperf-scout-meilisearch without Composer
On this page you can find all versions of the php package augustdai/hyperf-scout-meilisearch. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download augustdai/hyperf-scout-meilisearch
More information about augustdai/hyperf-scout-meilisearch
Files in augustdai/hyperf-scout-meilisearch
Package hyperf-scout-meilisearch
Short Description Hyperf MeiliSearch Scout provides a driver based solution to searching your Eloquent models.
License MIT
Informations about the package hyperf-scout-meilisearch
hyperf-scout-meilisearch
[目录]
简介
本扩展包为 Hyperf 框架提供了类似 Laravel Scout 的 Meilisearch 集成,支持文档索引、搜索、批量更新和批量同步索引设置等。
- 支持自定义索引名
- 支持批量添加/更新/删除文档
- 支持批量同步索引设置
环境要求
- PHP >= 8.1
- Hyperf >= 3.1
安装
配置
config/autoload/scout.php
.env
Model 配置
注意:getScoutKeyName 必须重写。 Hyperf 默认实现返回 table.column 格式(含点号),而 Meilisearch 不支持以点号作为主键字段名。
Hyperf 协程环境下的 MeilisearchProvider
在 Hyperf 协程(Swoole/Swow)环境中,Guzzle 的默认 curl handler 不是协程安全的,高并发导入时会出现 cURL error 0: unable to rewind body 错误。需要使用 Hyperf 提供的 HandlerStackFactory 替换默认 handler:
使用
建立索引(首次使用)
同步索引设置
同步 index-settings 中配置的 filterable/sortable/searchable 字段,无需传入模型名:
全量导入数据
大数据量快速导入(推荐):
通过 --chunk 参数增大每批条数,配合 scout.concurrency 提升并发,可显著缩短导入时间。
性能参考:
- 默认配置(chunk=500, concurrency=100):约 1,800 条/秒
- 推荐配置(chunk=5000, concurrency=200):约 5,000 条/秒
concurrency在config/autoload/scout.php的concurrency字段配置。
后台运行并记录日志:
删除索引数据
删除索引
搜索
详见 hyperf scout 官方文档:https://hyperf.wiki/3.1/#/zh-cn/scout
注意事项
- 主键字段名不能含点号(
.),必须重写getScoutKeyName()返回getKeyName() - 索引的 primary key 一旦设置不可更改,需要删除索引重建
addDocuments是 upsert 操作,重复导入同一主键只会覆盖,不会产生重复数据toSearchableArray()建议只返回需要搜索/过滤/排序的字段,避免索引体积过大
License
MIT
All versions of hyperf-scout-meilisearch with dependencies
guzzlehttp/guzzle Version ^7.9
http-interop/http-factory-guzzle Version ^1.0
hyperf/scout Version ^3.1
meilisearch/meilisearch-php Version ^1.15