PHPackages                             openplain/laravel-lightsearch - 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. [Database &amp; ORM](/categories/database)
4. /
5. openplain/laravel-lightsearch

ActiveLibrary[Database &amp; ORM](/categories/database)

openplain/laravel-lightsearch
=============================

A lightweight Laravel Scout driver using database-backed search index. Perfect for small to medium datasets (1K-50K records) without external search services.

v1.0.1(8mo ago)1286↓85%1[1 issues](https://github.com/openplain/laravel-lightsearch/issues)MITPHPPHP ^8.2CI passing

Since Oct 23Pushed 8mo agoCompare

[ Source](https://github.com/openplain/laravel-lightsearch)[ Packagist](https://packagist.org/packages/openplain/laravel-lightsearch)[ Docs](https://github.com/openplain/laravel-lightsearch)[ RSS](/packages/openplain-laravel-lightsearch/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (6)Versions (3)Used By (0)

Laravel LightSearch
===================

[](#laravel-lightsearch)

[![Latest Version on Packagist](https://camo.githubusercontent.com/93cef2c4b3d51abf063d301d8240109cb6881f9e8a3d72f43fe78fdb9bf23933/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f70656e706c61696e2f6c61726176656c2d6c696768747365617263682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/openplain/laravel-lightsearch)[![Total Downloads](https://camo.githubusercontent.com/6ce1536f126c41274626d457c44343297ed0b513034071948a9ba4ed5236d293/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f70656e706c61696e2f6c61726176656c2d6c696768747365617263682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/openplain/laravel-lightsearch)

Fast, database-backed search for Laravel Scout. No external services, no monthly fees, no infrastructure complexity.

Why This Package?
-----------------

[](#why-this-package)

We created LightSearch because most Laravel applications don't need the complexity of external search services like Algolia or Meilisearch. For small to medium datasets, your existing database is perfectly capable of delivering fast, relevant search results.

**Our Goal:** Make search simple enough for MVPs, powerful enough for production, and cost-effective for bootstrapped projects.

**Real-world performance**: 2.95ms average search time on 26,000+ records ([view benchmark](BENCHMARK_RESULTS.md))

### Built on Proven Technology

[](#built-on-proven-technology)

Rather than reinventing the wheel, LightSearch leverages:

- **Laravel Scout** - Familiar API that works across all search drivers
- **Inverted Index Pattern** - Classic search architecture used by Meilisearch, Algolia, and Typesense
- **Database-Specific Optimizations** - PostgreSQL `pg_trgm` for fuzzy search, MySQL/SQLite optimized queries

Features
--------

[](#features)

- 🚀 **Database-Backed** - Uses your existing MySQL, PostgreSQL, or SQLite database
- 💰 **Zero Cost** - No external services, no monthly fees
- ⚡ **Fast Setup** - From install to working search in under 5 minutes
- 🎯 **Field Weighting** - Boost relevance of important fields (title &gt; content)
- 🔍 **Fuzzy Search** - Typo-tolerant search on PostgreSQL with `pg_trgm`
- 🌍 **Unicode Support** - Perfect handling of special characters (ø, á, ñ, etc.)
- 🔧 **Customizable** - Stopwords, token length, field weights all configurable
- 📦 **Scout Compatible** - Drop-in replacement for Scout drivers
- 🔑 **UUID Support** - Works with string primary keys, not just integers

When to Use LightSearch
-----------------------

[](#when-to-use-lightsearch)

**Perfect for:**

- Small to medium datasets (1K-50K records)
- Budget-constrained projects
- MVPs and prototypes
- Applications already using Laravel Scout
- Simple hosting environments (no Docker required)

**Not Ideal for:**

- Large datasets (&gt;100K records) → use Meilisearch, Algolia, or Typesense
- Complex multi-language search → use Algolia or Typesense
- Real-time autocomplete with sub-10ms response times
- Advanced features like faceted search, geo-search, or AI-powered ranking

Requirements
------------

[](#requirements)

- PHP 8.2 or higher
- Laravel 11 or 12
- Laravel Scout 10 or higher

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require openplain/laravel-lightsearch
```

Publish and run migrations:

```
php artisan vendor:publish --tag=lightsearch-migrations
php artisan migrate
```

Optionally publish the configuration file:

```
php artisan vendor:publish --tag=lightsearch-config
```

Quick Start
-----------

[](#quick-start)

### 1. Configure Scout Driver

[](#1-configure-scout-driver)

Set LightSearch as your Scout driver in `.env`:

```
SCOUT_DRIVER=lightsearch
```

### 2. Make Your Model Searchable

[](#2-make-your-model-searchable)

Add the `Searchable` trait and define searchable fields:

```
