PHPackages                             loupe/loupe - 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. loupe/loupe

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

loupe/loupe
===========

A full text search engine with tokenization, stemming, typo tolerance, filters and geo support based on only PHP and SQLite

1.0.1(2w ago)513280.5k↓66.1%26[4 issues](https://github.com/loupe-php/loupe/issues)[5 PRs](https://github.com/loupe-php/loupe/pulls)11MITPHPPHP ^8.1CI passing

Since Aug 1Pushed 2w ago11 watchersCompare

[ Source](https://github.com/loupe-php/loupe)[ Packagist](https://packagist.org/packages/loupe/loupe)[ GitHub Sponsors](https://github.com/Toflar)[ RSS](/packages/loupe-loupe/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (10)Dependencies (82)Versions (102)Used By (11)

 [![Loupe](./logo/logo.svg)](./logo/logo.svg)
 **An SQLite based, PHP-only fulltext search engine.**

> Read the documentation: [loupe-php.github.io/loupe](https://loupe-php.github.io/loupe/)

Loupe…

- only requires PHP and SQLite, you don't need anything else - no containers, no nothing
- is typo-tolerant (based on the State Set Index Algorithm and Damerau-Levenshtein)
- supports phrase search using `"` quotation marks
- supports negative keyword and phrase search using `-` as modifier
- supports filtering (and ordering) on any attribute with any SQL-inspired filter statement
- supports filtering (and ordering) on Geo distance
- supports search facets
- orders relevance based on a number of factors such as number of matching terms, typos, proximity, word counts and exactness
- crops attributes to show the most relevant context around matched terms
- auto-detects languages
- supports stemming
- automatically decomposes English and German compound words, so searching for `brush` finds `toothbrush`
- is very easy to use
- is all-in-all just the easiest way to replace your good old SQL `LIKE %...%` queries with a way better search experience but without all the hassle of an additional service to manage. SQLite is everywhere and all it needs is your filesystem.

Introductory blog post
----------------------

[](#introductory-blog-post)

If this is your first encounter with Loupe, you might want to read the [blog post on Medium](https://medium.com/@yanick.witschi/loupe-a-search-engine-with-only-php-and-sqlite-1c0d83024a71) or [as Markdown file](./docs/blog_post.md) that should give you more information about the reasons and what you can do with it. Note that some implementation details (e.g. libraries used) referenced in this blog post are not up-to-date anymore.

Performance
-----------

[](#performance)

Performance depends on many factors but here are some ballpark numbers based on indexing the [~32k movies fixture](https://www.meilisearch.com/movies.json) provided by MeiliSearch.

- **Querying** for `Amakin Dkywalker` with typo tolerance and relevance ranking takes **&lt; 20 ms**
- **Indexing** varies greatly because it depends on how much content per document you want to index

Note that anything above 50k documents is probably not a use case for Loupe. You can run your own benchmarks with [PHPBench](https://github.com/phpbench/phpbench):

```
composer bench         # SearchBench + FilterBench (query latency)
composer bench-index   # IndexBench (cold-insert + update; slower)
```

The benches in `tests/Benchmark` run against the [~32k movies fixture](https://www.meilisearch.com/movies.json), which is downloaded automatically into `var/movies.json` on first run. A shared search index is built once into `var/bench/` and reused across `composer bench` runs.

Please, also read the [Performance](./docs/performance.md) chapter in the docs. You may report your own performance measurements and more details in the [respective discussion](https://github.com/loupe-php/loupe/discussions/17).

Acknowledgement
---------------

[](#acknowledgement)

If you are familiar with MeiliSearch, you will notice that the API is very much inspired by it. The reasons for this are simple:

1. First and foremost: I think, they did an amazing job of keeping configuration simple and understandable from a developer's perspective. Basic search tools shouldn't be complicated.
2. If Loupe shouldn't be enough for your use case anymore (you need advanced features, better performance etc.), switching to MeiliSearch instead should be a piece of cake.

I even took the liberty to copy some of their test data to feed Loupe for functional tests.

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

[](#installation)

1. Make sure you have `pdo_sqlite` available and your installed SQLite version is at least 3.35.0. This is when RETURNING functions have been added without which no bulk inserts are possible. For best performance it is of course better to run a more recent version to benefit from improvements within SQLite.
2. Run `composer require loupe/loupe`.

Usage
-----

[](#usage)

### Creating a client

[](#creating-a-client)

The first step is configuring and creating a client.

```
use Loupe\Loupe\Config\TypoTolerance;
use Loupe\Loupe\Configuration;
use Loupe\Loupe\LoupeFactory;
use Loupe\Loupe\SearchParameters;

$configuration = Configuration::create()
    ->withPrimaryKey('uuid') // optional, by default it's 'id'
    ->withSearchableAttributes(['firstname', 'lastname']) // optional, by default it's ['*'] - everything is indexed
    ->withFilterableAttributes(['departments', 'age'])
    ->withSortableAttributes(['lastname'])
    ->withTypoTolerance(TypoTolerance::create()->withFirstCharTypoCountsDouble(false)) // can be further fine-tuned but is enabled by default
;

$loupe = (new LoupeFactory())->create('path/to/my_loupe_data_dir', $configuration);
```

To create an in-memory search client:

```
$loupe = (new LoupeFactory())->createInMemory($configuration);
```

### Adding documents

[](#adding-documents)

```
$loupe->addDocuments([
    [
        'uuid' => 2,
        'firstname' => 'Uta',
        'lastname' => 'Koertig',
        'departments' => [
            'Development',
            'Backoffice',
        ],
        'age' => 29,
    ],
    [
        'uuid' => 6,
        'firstname' => 'Huckleberry',
        'lastname' => 'Finn',
        'departments' => [
            'Backoffice',
        ],
        'age' => 18,
    ],
]);
```

### Performing search

[](#performing-search)

```
$searchParameters = SearchParameters::create()
    ->withQuery('Gucleberry')
    ->withAttributesToRetrieve(['uuid', 'firstname'])
    ->withFilter("(departments = 'Backoffice' OR departments = 'Project Management') AND age > 17")
    ->withFacets(['departments', 'age'])
    ->withSort(['lastname:asc'])
;

$results = $loupe->search($searchParameters);
```

The `$results` array contains a list of search hits and metadata about the query.

```
print_r($results->toArray());

[
    'hits' => [
        [
            'uuid' => 6,
            'firstname' => 'Huckleberry'
        ]
    ],
    'query' => 'Gucleberry',
    'processingTimeMs' => 4,
    'hitsPerPage' => 20,
    'page' => 1,
    'totalPages' => 1,
    'totalHits' => 1,
    'facetDistribution' => [
        'departments' => [
            'Backoffice' => 1,
        ],
    ],
    'facetStats' => [
        'age' => [
            'min' => 18,
            'max' => 18,
        ],
    ],
]
```

Docs
----

[](#docs)

The documentation is available at [loupe-php.github.io/loupe](https://loupe-php.github.io/loupe/).

- [Schema](./docs/schema.md)
- [Configuration](./docs/configuration.md)
- [Indexing](./docs/indexing.md)
- [Searching](./docs/searching.md)
- [Browsing](./docs/browsing.md)
- [Ranking](./docs/ranking.md)
- [Tokenizer](./docs/tokenizer.md)
- [Performance](./docs/performance.md)

"Why Loupe?" you ask? "Loupe" means "magnifier" in French and I felt like this was the appropriate choice for this library after having given [my PHP crawler library](https://github.com/terminal42/escargot) a French name :-)

###  Health Score

68

—

FairBetter than 99% of packages

Maintenance96

Actively maintained with recent releases

Popularity57

Moderate usage in the ecosystem

Community38

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 83.9% 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 ~12 days

Recently: every ~7 days

Total

86

Last Release

19d ago

Major Versions

0.13.23 → 1.0.02026-07-30

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/481937?v=4)[Yanick Witschi](/maintainers/Toflar)[@Toflar](https://github.com/Toflar)

---

Top Contributors

[![Toflar](https://avatars.githubusercontent.com/u/481937?v=4)](https://github.com/Toflar "Toflar (313 commits)")[![daun](https://avatars.githubusercontent.com/u/22225348?v=4)](https://github.com/daun "daun (35 commits)")[![alexander-schranz](https://avatars.githubusercontent.com/u/1698337?v=4)](https://github.com/alexander-schranz "alexander-schranz (8 commits)")[![MaximilianKresse](https://avatars.githubusercontent.com/u/545671?v=4)](https://github.com/MaximilianKresse "MaximilianKresse (3 commits)")[![discordier](https://avatars.githubusercontent.com/u/940331?v=4)](https://github.com/discordier "discordier (2 commits)")[![zonky2](https://avatars.githubusercontent.com/u/1045318?v=4)](https://github.com/zonky2 "zonky2 (2 commits)")[![fiedsch](https://avatars.githubusercontent.com/u/5047601?v=4)](https://github.com/fiedsch "fiedsch (1 commits)")[![hirasso](https://avatars.githubusercontent.com/u/869813?v=4)](https://github.com/hirasso "hirasso (1 commits)")[![norkunas](https://avatars.githubusercontent.com/u/2722872?v=4)](https://github.com/norkunas "norkunas (1 commits)")[![doishub](https://avatars.githubusercontent.com/u/48379929?v=4)](https://github.com/doishub "doishub (1 commits)")[![ovenum](https://avatars.githubusercontent.com/u/47149622?v=4)](https://github.com/ovenum "ovenum (1 commits)")[![panda-madness](https://avatars.githubusercontent.com/u/6180087?v=4)](https://github.com/panda-madness "panda-madness (1 commits)")[![qzminski](https://avatars.githubusercontent.com/u/193483?v=4)](https://github.com/qzminski "qzminski (1 commits)")[![ausi](https://avatars.githubusercontent.com/u/367169?v=4)](https://github.com/ausi "ausi (1 commits)")[![nz-chris](https://avatars.githubusercontent.com/u/37297133?v=4)](https://github.com/nz-chris "nz-chris (1 commits)")[![DumbergerL](https://avatars.githubusercontent.com/u/12397678?v=4)](https://github.com/DumbergerL "DumbergerL (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleECS

Type Coverage Yes

### Embed Badge

![Health badge](/badges/loupe-loupe/health.svg)

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

###  Alternatives

[symfony/symfony

The Symfony PHP framework

31.4k87.4M2.2k](/packages/symfony-symfony)[symfony/cache

Provides extended PSR-6, PSR-16 (and tags) implementations

4.2k382.4M3.7k](/packages/symfony-cache)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k6.0M777](/packages/sylius-sylius)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.8M672](/packages/shopware-core)[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)

PHPackages © 2026

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