Repolode
teamtnt

teamtnt/tntsearch

A full-text search engine library for PHP that builds indexes in SQLite, MySQL, or Redis and returns ranked document IDs.

Stars
3,201
Forks
296
Open issues
56
Last commit
3 days ago

What is it?

TNTSearch is a PHP library for adding full-text search to an application without running a separate search server. You point it at a data source such as a SQLite, MySQL, or PostgreSQL database or a folder of text files, build an index file, and then run queries against it. Indexes are stored in SQLite by default, with MySQL and Redis engines also available, and they can be updated with insert, update, and delete calls without a full rebuild.

Search supports relevance ranking with BM25 and TF-IDF, boolean queries with AND, OR, and NOT, fuzzy matching with configurable edit distance, and search-as-you-type prefix matching. It also includes stemmers for several languages, custom tokenizers, result highlighting and snippets, geo-based nearest-point search, and a simple text classifier.

The search methods return document IDs and scores rather than full rows, so the application fetches the matching records from its own database and keeps the returned order. A Laravel Scout driver is available as a separate package.

Key features

  • 01Relevance ranking with BM25 and TF-IDF
  • 02Boolean search with AND, OR, and NOT operators
  • 03Fuzzy matching with adjustable edit distance and prefix length
  • 04Search-as-you-type prefix matching
  • 05Index storage in SQLite, MySQL, or Redis with incremental updates
  • 06Stemmers for multiple languages and custom tokenizers

Use cases

  • Adding site or product search to a PHP or Laravel application without a separate search server
  • Searching a document collection stored as text files
  • Finding nearby points of interest by coordinates
  • Adding simple text classification to a PHP project

Quick start

  1. 1

    Install the library with Composer

    composer require teamtnt/tntsearch
  2. 2

    Configure TNTSearch, build an index from your source query, then select it and search

Things to know

  • Search returns document IDs and scores, not the documents, so you must fetch rows from your own database.
  • Requires PHP 7.4 or newer with the pdo_sqlite extension for the default engine.

In collections

Topics

FAQ

What is tntsearch?
A full-text search engine library for PHP that builds indexes in SQLite, MySQL, or Redis and returns ranked document IDs. TNTSearch is a PHP library for adding full-text search to an application without running a separate search server. You point it at a data source such as a SQLite, MySQL, or PostgreSQL database or a folder of text files, build an index file, and then run queries against it. Indexes are stored in SQLite by default, with MySQL and Redis engines also available, and they can be updated with insert, update, and delete calls without a full rebuild.
Is tntsearch free to use? What license does it have?
tntsearch is open source under the MIT license. Check the license terms before using it in commercial products.
Is tntsearch still maintained?
Actively maintained. The last commit to tntsearch was on Nov 3, 2026.
What can I use tntsearch for?
Adding site or product search to a PHP or Laravel application without a separate search server Searching a document collection stored as text files Finding nearby points of interest by coordinates Adding simple text classification to a PHP project
How do I install tntsearch?
Install the library with Composer: composer require teamtnt/tntsearch Configure TNTSearch, build an index from your source query, then select it and search
Where can I get tntsearch?
The source code and installation instructions are on GitHub: https://github.com/teamtnt/tntsearch

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects