Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
L

loupe

> 编程语言
Open source

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

513 stars0 likes0 views
WebsiteGitHub

About

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

Read the documentation: 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

If this is your first encounter with Loupe, you might want to read the blog post on Medium or as Markdown file 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 depends on many factors but here are some ballpark numbers based on indexing the ~32k movies fixture provided by MeiliSearch.

  • Querying for Amakin Dkywalker with typo tolerance and relevance ranking takes **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:

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

Adding documents

php
$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

php
$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.

php
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

The documentation is available at loupe-php.github.io/loupe.

  • Schema
  • Configuration
  • Indexing
  • Searching
  • Browsing
  • Ranking
  • Tokenizer
  • Performance

"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 a French name :-)

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

PHP

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言