jord-jd/laravel-omega-search
Composer 安装命令:
composer require jord-jd/laravel-omega-search
包简介
Easily add an intelligent search engine to your Laravel powered website or web application
README 文档
README
Omega Search allows you to easily add an intelligent search engine to your Laravel powered website or web application. It can be configured to search any of your Eloquent models.
Under the hood, this uses the Omega Search package.
Installation
You can install this package with Composer.
composer require jord-jd/laravel-omega-search
Usage
To use Laravel Omega Search, first add the OmegaSearchTrait
to the models you wish to search. You must then implement
the following two abstract methods.
getOmegaSearchFieldsToSearch()- Must return an array of the model's fields to search.getOmegaSearchConditions()- Must return an associative array of the search conditions. Example:['active' => 1, 'discontinued' => 0]
After this setup, a search can be performed by calling
the static omegaSearch($searchText) method on the model.
This method performs an intelligent fuzzy search, and returns
a query builder filtered to the related records in descending
order of relevance.
The related models can then be retrieved (->get()) or
paginated (->paginate()) as required.
Joining Tables
If you want to search the content of related tables, you can use joins. Simply override the getOmegaSearchTablesToJoin on your model and return an array of OmegaSearchJoins.
Defining Joins
Join by related keys
There are two ways to define joins. The first way is to call the OmegaSearchJoin::joinTableByForeignKey method. You have to pass the local table name and joined table name to this method.
By default the key on the joined table will be the joined table name singularised with _id appended and the key on the local table will id. These can be set manually using the 3rd and 4th parameter for this method.
See below for an example:
public function getOmegaSearchTablesToJoin() { return [ OmegaSearchJoin::joinTableByForeignKey($this->getTable(), 'divisions'), ]; }
or
public function getOmegaSearchTablesToJoin() { return [ OmegaSearchJoin::joinTableByForeignKey($this->getTable(), 'divisions', 'id', 'division_id), ]; }
You can chain joins as seen below:
public function getOmegaSearchTablesToJoin() { return [ OmegaSearchJoin::joinTableByForeignKey($this->getTable(), 'divisions'), OmegaSearchJoin::joinTableByForeignKey('divisions', 'companies', 'id', 'company_id') ]; }
Join Manually
If you want to join tables that are not just linked by related keys you can manually add conditions to a join. To do this create a new OmegaSearchJoin object and call the addCondition method to add your conditions. You must specify the local table name and the joined table name in the constructor. Optionally you can specify the join type, the default is JOIN
When adding a condition the parameter on the left will automatically have the local table name prepended and the joined table name will be prepended to the right condition.
See below for an example:
public function getOmegaSearchTablesToJoin() { $join = new OmegaSearchJoin('contacts', 'divisions', 'INNER JOIN'); $join->addCondition('gross_income', '>', 'annual_income'); return [ $join, ]; }
jord-jd/laravel-omega-search 适用场景与选型建议
jord-jd/laravel-omega-search 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 10, 最近一次更新时间为 2026 年 02 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 jord-jd/laravel-omega-search 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jord-jd/laravel-omega-search 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 10
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: LGPL-3.0-only
- 更新时间: 2026-02-14