omure/scout-advanced-meilisearch 问题修复 & 功能扩展

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

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

omure/scout-advanced-meilisearch

Composer 安装命令:

composer require omure/scout-advanced-meilisearch

包简介

Laravel Scout extension that allows to use meilisearch advanced features as well as has an extended collection driver for testing purposes.

README 文档

README

What this package provides

Extended scout query builder

Added next changes to the basic query builder:

  1. where('column', '<=', $value) - extended where, which supports 3 optional parameters for comparison. Two parameters are also allowed.
  2. where(Clusure $query) - where can take a closure as the first parameter in order to group queries (the same for orWhere)
  3. whereBetween('column', [$value1, $value2])
  4. whereNotIn('column', [$value1, $value2, $value3])
  5. All where clauses have or variant: orWhere, orWhereIn, etc

Two scout drivers

The drivers are compatible with the new scout builder.

  • meilisearch_advanced
  • collection_advanced

meilisearch_advanced

Uses all the advantages of meilisearch for comparison the results, searching in indexed arrays. Also fixes an issue with the calculation of the total number of values. (The current implementation requests the entire dataset in case scout builder has ->query() method used)

collection_advanced

The driver imitates how meilisearch work and completely relies on collections. It should be used only for tests as the whole searchable models data is in memory. The driver allows testing filtering and sorting as well as Extended scout builder features.

Meilisearch specific are taken into account

Meilisearch requires updating indexes filterable, sortable and searchable attributes in order to save the indexing data properly. This package provides MeiliSearch facade that has updateIndexSettings method that handles that automatically.

How to use?

  1. In config/scout.php set 'driver' to meilisearch_advanced or collection_advanced
  2. Apply Searchable trait to the model (Omure\ScoutAdvancedMeilisearch\Searchable);
  3. For proper handling of the model, implement Omure\ScoutAdvancedMeilisearch\Interfaces\MeiliSearchSearchableModel interface to the model
  4. Describe indexed parameters for searching in toSearchableArray() method of the model (the same way as Scout does)
  5. Specify searchable, filterable and sortable attributes by defining the next list of methods on the model:
  • getSearchableAttributes() - for using search() statements
  • getFilterableAttributes() - for using where(), including whereIn, whereNotIn, etc. statements
  • getSortableAttributes() - for using orderBy() statement
  • getTypoToleranceSettings() - for typo tolerance All methods should return an array of strings which are the names of the parameters specified in toSearchableArray().

If you change the methods getSearchableAttributes(), getFilterableAttributes(), or getSortableAttributes() returned indexes, you have to let meilisearch know about the changes. For that purpose use the facade: MeiliSearch::updateIndexSettings(new User());

The method takes a model instance to update the parameters on the meilisearch server.

Keep in mind that toSearchableArray() doesn't have to have the same indexes as the database column names. You can specify your own logic for searching and filtering. Use the specified parameters in your Scout Builder.

omure/scout-advanced-meilisearch 适用场景与选型建议

omure/scout-advanced-meilisearch 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.87k 次下载、GitHub Stars 达 12, 最近一次更新时间为 2022 年 05 月 24 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 omure/scout-advanced-meilisearch 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 3.87k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 12
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 12
  • Watchers: 1
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-05-24