PHPackages                             tzart/search-engine - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Search &amp; Filtering](/categories/search)
4. /
5. tzart/search-engine

ActiveLibrary[Search &amp; Filtering](/categories/search)

tzart/search-engine
===================

A JSON-tree based fuzzy search engine for Laravel with multi-domain and category filtering.

1.2.5(2mo ago)044MITPHPPHP ^7.4|^8.0

Since Sep 23Pushed 2mo agoCompare

[ Source](https://github.com/tushar-2022/SearchEngine)[ Packagist](https://packagist.org/packages/tzart/search-engine)[ RSS](/packages/tzart-search-engine/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (2)Versions (27)Used By (0)

🔎 Laravel Search Engine

A JSON-tree based fuzzy search engine for Laravel with:

Multi-domain support (separate indexes per domain),

Autocomplete (prefix suggestions),

Fuzzy search (handles typos like aple → apple),

Category filtering (by category IDs, not titles),

Configurable tree structure stored as JSON for super-fast lookups.

Supports dynamic model/column mapping so you can plug in any Term/Category models without code changes.

🚀 Installation

Require the package:

composer require tzart/search-engine

⚙️ Configuration

Publish the config:

php artisan vendor:publish --tag=search-config

This creates config/search.php:

return \[

```
'models' => [
    'term'     => App\Term::class,
    'category' => App\Category::class,
],

'columns' => [
    'term_id'    => 'id',
    'term_title' => 'title',
    'term_type'  => 'type',      // optional, can be null
    'domain_id'  => 'domain_id', // set null if not used
],

'search' => [
    'fuzzy_threshold'   => 2,
    'similarity_ratio'  => 40,
    'tree_path'         => storage_path('app/search/trees'),
    'branch_distance'   => 1,
    'min_candidates'    => 25,
    'token_mode'        => 'any',   // 'any' or 'all'
    'substring_min_len' => 3,
    'substring_boost'   => 20,
    'prefix_boost'      => 30,
    'return'            => 'ids',   // default return format
],

```

\];

📖 Usage Build the tree index

Per-domain (if domain\_id column is configured):

Search::buildIndex(1); // build for domain\_id = 1 Search::buildIndex(2); // build for domain\_id = 2

Global (if domain\_id is null in config):

Search::buildIndex(); // builds one tree\_all.json

Autocomplete $suggestions = Search::autocomplete('aple', 1);

// → \[12, 15, 17\] (Term IDs)

Fuzzy Search $results = Search::search('product', 1, \[ 'category\_ids' =&gt; \[10, 12\], 'return' =&gt; 'nodes', // full nodes instead of just IDs 'limit' =&gt; 15 \]);

/\* \[ \[ "id" =&gt; 123, "title" =&gt; "Product with 4 Prems", "type" =&gt; "sku", "domain\_id" =&gt; 1, "category\_ids" =&gt; \[10,12\] \], ... \] \*/

🛠 Features

Phonetic tree branches: uses metaphone() to cluster similar words (so "aple" and "apple" share a branch).

Token + phrase indexing: splits by tokens for flexible matches ("product with 4 prems" found when searching "product").

Configurable fuzzy matching: tune similarity %, Levenshtein distance, substring/prefix boosts.

Fast JSON lookups: indexes stored as JSON in storage/app/search/trees/.

📂 JSON Tree Format

Each branch groups together similar terms:

{ "T:APPL": \[ { "id": 12, "title": "Apple", "type": "fruit", "domain\_id": 1, "category\_ids": \[2, 5\] }, { "id": 15, "title": "Maple", "type": "tree", "domain\_id": 1, "category\_ids": \[7\] } \] }

📌 Roadmap

🔄 Optional Elasticsearch driver for larger datasets.

🗄 Artisan command php artisan search:rebuild for scheduled rebuilds.

🚀 Multi-language phonetic clustering.

📜 License

MIT © 2025 — tzart/search-engine

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance86

Actively maintained with recent releases

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~7 days

Recently: every ~34 days

Total

26

Last Release

67d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/879620f7852ed6448062e1f1e03e41fe881127475d6b43fe83ab6ee4bee8ed3e?d=identicon)[Tzar](/maintainers/Tzar)

---

Top Contributors

[![tushar-assessprep](https://avatars.githubusercontent.com/u/152849220?v=4)](https://github.com/tushar-assessprep "tushar-assessprep (30 commits)")[![tushar-2022](https://avatars.githubusercontent.com/u/107827363?v=4)](https://github.com/tushar-2022 "tushar-2022 (2 commits)")

---

Tags

jsonsearchlaravelautocompletecategoriesfuzzy

### Embed Badge

![Health badge](/badges/tzart-search-engine/health.svg)

```
[![Health](https://phpackages.com/badges/tzart-search-engine/health.svg)](https://phpackages.com/packages/tzart-search-engine)
```

###  Alternatives

[mailerlite/laravel-elasticsearch

An easy way to use the official PHP ElasticSearch client in your Laravel applications.

934529.3k2](/packages/mailerlite-laravel-elasticsearch)[jeroen-g/explorer

Next-gen Elasticsearch driver for Laravel Scout.

397612.3k](/packages/jeroen-g-explorer)[rap2hpoutre/similar-text-finder

Fuzzy Search, similar text finder: "Did you mean `foo` ?"

13877.7k3](/packages/rap2hpoutre-similar-text-finder)[remoblaser/search

A simple to implement Search for your Application

101.5k](/packages/remoblaser-search)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
