onstage2426 / fuzor
Dependency-free full-text search for PHP. BM25 ranking, fuzzy and boolean modes, search-as-you-type prefix matching, stopword filtering and Snowball stemming for 62 languages, snippet extraction and result highlighting — one SQLite file, zero infrastructure.
3.5.0
2026-05-15 11:40 UTC
Requires
- php: >=8.5
Requires (Dev)
- infection/infection: ^0.32.6
- phpbench/phpbench: ^1.5
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^13.1
- rector/rector: ^2.4
- squizlabs/php_codesniffer: ^4.0
README
About
Fuzor is a dependency-free full-text search library for PHP. It tokenises your documents, stores an inverted index in a single SQLite file, and scores results with Okapi BM25 — no external services required.
- BM25 ranked search with fuzzy and boolean modes
- Faceted search — filter by attribute values and compute per-value counts
- Search-as-you-type prefix matching
- Stopword filtering and Snowball stemming for 62 languages
- Snippet extraction and result highlighting
- One SQLite file per index — zero infrastructure
Installation
composer require onstage2426/fuzor
Requirements: PHP 8.5+, SQLite 3.46.0+
Usage
use Fuzor\Index; use Fuzor\FacetRange; // Create an index and add documents $index = new Index('/path/to/products.db', language: 'en', facets: true); $index->insertMany([ ['id' => 1, 'title' => 'Fast sedan', 'body' => 'City car with great fuel economy.', '_facets' => ['type' => 'sedan', 'price' => 24900]], ['id' => 2, 'title' => 'Off-road SUV', 'body' => 'Built for adventure and any terrain.', '_facets' => ['type' => 'suv', 'price' => 41500]], ['id' => 3, 'title' => 'Electric coupe', 'body' => 'Zero emissions and instant torque.', '_facets' => ['type' => 'coupe', 'price' => 58000]], ]); // BM25 search (with optional fuzzy matching) $results = $index->search('economi', fuzzy: true); // Boolean search $results = $index->searchBoolean('sedan or coupe -electric'); // Faceted search — filter by attribute, get counts per value $results = $index->search('car', filter: ['type' => ['sedan', 'suv'], 'price' => FacetRange::max(45000)], facets: ['type']);
Documentation
- Indexing — bulk loading, facet values, upsert, rebuild, snapshots
- Search — BM25 tuning, fuzzy, boolean, prefix, facet filtering and counts
- Language — stopwords, stemming, CJK/Thai n-grams
- Configuration — all tuning parameters
- Document store — store and retrieve raw documents
- Snippeting and Highlighting
- Query inspection and Performance
License
MIT — see LICENSE.