PHPackages                             woodfish/tntsearch-chinese - 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. woodfish/tntsearch-chinese

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

woodfish/tntsearch-chinese
==========================

A fully featured full text search engine written in PHP

v1.0.0(9y ago)4164MITPHPPHP ~5.5|~7.0

Since Apr 6Pushed 9y ago1 watchersCompare

[ Source](https://github.com/swooder/tntsearch-chinese)[ Packagist](https://packagist.org/packages/woodfish/tntsearch-chinese)[ Docs](https://github.com/teamtnt/tntsearch)[ RSS](/packages/woodfish-tntsearch-chinese/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (2)Versions (28)Used By (0)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4f89b6a1ccd11f763ecd04c14b2f2ce009d1f7c744bea0b755341f82e5cba91b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7465616d746e742f746e747365617263682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/teamtnt/tntsearch)[![Total Downloads](https://camo.githubusercontent.com/213ea2619b7e2e01fbd39ba8dcc063b20843092fa22072e05c4805a57cc2f994/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7465616d746e742f746e747365617263682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/teamtnt/tntsearch)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/ea231847a079e76681f29dae7faad73bc38a2b847db8d89ae010bec05064ad12/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7465616d746e742f746e747365617263682f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/teamtnt/tntsearch)[![Slack Status](https://camo.githubusercontent.com/5b0d02a0a48f4e33ae9045e780073b25616ea87b97f71804604c58c45368627c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f736c61636b2d636861742d4530313536332e7376673f7374796c653d666c61742d737175617265)](https://tntsearch.slack.com)

\#TNTSearch

A fully featured full text search engine written in PHP

[![TNTSearch Banner](https://cloud.githubusercontent.com/assets/824840/17067635/edf2ae50-504c-11e6-9c63-a73955f55c29.jpg)](https://cloud.githubusercontent.com/assets/824840/17067635/edf2ae50-504c-11e6-9c63-a73955f55c29.jpg)

\##Demo

To see TNTSearch in action take a look at [the demo page](http://tntsearch.tntstudio.us/)

\##Tutorials

- [Solving the search problem with Laravel and TNTSearch](http://tnt.studio/blog/solving-the-search-problem-with-laravel-and-tntsearch)
- [Searching for Bobby Fisher with Laravel 5](http://tnt.studio/blog/searching-for-bobby-fisher-with-laravel-5)

\##Installation

The easiest way to install TNTSearch is via [composer](http://getcomposer.org/):

```
composer require teamtnt/tntsearch

```

\##Requirements

Before you proceed make sure your server meets the following requirements:

- PHP &gt;= 5.5
- PDO PHP Extension
- SQLite PHP Extension
- mbstring PHP Extension

\##Examples

### Creating an index

[](#creating-an-index)

In order to be able to make full text search queries you have to create an index.

Usage:

```
use TeamTNT\TNTSearch\TNTSearch;

$tnt = new TNTSearch;

$tnt->loadConfig([
    'driver'    => 'mysql',
    'host'      => 'localhost',
    'database'  => 'dbname',
    'username'  => 'user',
    'password'  => 'pass',
    'storage'   => '/var/www/tntsearch/examples/'
]);

$indexer = $tnt->createIndex('name.index');
$indexer->query('SELECT id, article FROM articles;');
//$indexer->setLanguage('german');
$indexer->run();
```

Important: "storage" settings marks the folder where all of your indexes will be saved so make sure to have permission to write to this folder otherwise you might expect the following exception thrown:

- \[PDOException\] SQLSTATE\[HY000\] \[14\] unable to open database file \*

Note: If your primary key is different that `id` set it like:

```
$indexer->setPrimaryKey('article_id');
```

### Searching

[](#searching)

Searching for a phrase or keyword is trivial

```
use TeamTNT\TNTSearch\TNTSearch;

$tnt = new TNTSearch;

$tnt->loadConfig($config);
$tnt->selectIndex("name.index");

$res = $tnt->search("This is a test search", 12);

print_r($res); //returns an array of 12 document ids that best match your query

//to display the results you need an additional query
//SELECT * FROM articles WHERE id IN $res ORDER BY FIELD(id, $res);
```

The ORDER BY FIELD clause is important otherwise the database engine will not return the results in required order

### Boolean Search

[](#boolean-search)

```
use TeamTNT\TNTSearch\TNTSearch;

$tnt = new TNTSearch;

$tnt->loadConfig($config);
$tnt->selectIndex("name.index");

//this will return all documents that have romeo in it but not juliet
$res = $tnt->searchBoolean("romeo -juliet");

//returns all documents that have romeo or hamlet in it
$res = $tnt->searchBoolean("romeo or hamlet");

//returns all documents that have either romeo AND juliet or prince AND hamlet
$res = $tnt->searchBoolean("(romeo juliet) or (prince hamlet)");
```

### Fuzzy Search

[](#fuzzy-search)

The fuzziness can be tweaked by setting the following member variables:

```
public $fuzzy_prefix_length  = 2;
public $fuzzy_max_expansions = 50;
public $fuzzy_distance       = 2 //represents the levenshtein distance;
```

```
use TeamTNT\TNTSearch\TNTSearch;

$tnt = new TNTSearch;

$tnt->loadConfig($config);
$tnt->selectIndex("name.index");
$tnt->fuzziness = true;

//when the fuzziness flag is set to true the keyword juleit will return
//documents that match the word juliet, the default levenshtein distance is 2
$res = $tnt->search("juleit");
```

Updating the index
------------------

[](#updating-the-index)

Once you created an index you don't need to reindex it each time you make some changes to your document collection. TNTSearch supports dynamic index updates.

```
use TeamTNT\TNTSearch\TNTSearch;

$tnt = new TNTSearch;

$tnt->loadConfig($config);
$tnt->selectIndex("name.index");

$index = $tnt->getIndex();

//to insert a new document to the index
$index->insert(['id' => '11', 'title' => 'new title', 'article' => 'new article']);

//to update an existing document
$index->update(11, ['id' => '11', 'title' => 'updated title', 'article' => 'updated article']);

//to delete the document from index
$index->delete(12);
```

Drivers
-------

[](#drivers)

- [TNTSearch Driver for Laravel Scout](https://github.com/teamtnt/laravel-scout-tntsearch-driver)

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.

Credits
-------

[](#credits)

- [Nenad Tičarić](https://github.com/nticaric)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 92.7% 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 ~9 days

Recently: every ~19 days

Total

27

Last Release

3483d ago

Major Versions

v0.9.0 → v1.0.02016-12-15

### Community

Maintainers

![](https://www.gravatar.com/avatar/5f688332d4e259ba48f6f83c6f57c56a498d1d2d99cd3205ba1ef2a87d4ecaf9?d=identicon)[woodfish](/maintainers/woodfish)

---

Top Contributors

[![nticaric](https://avatars.githubusercontent.com/u/824840?v=4)](https://github.com/nticaric "nticaric (164 commits)")[![tpodg](https://avatars.githubusercontent.com/u/896029?v=4)](https://github.com/tpodg "tpodg (4 commits)")[![stokic](https://avatars.githubusercontent.com/u/2147162?v=4)](https://github.com/stokic "stokic (3 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (2 commits)")[![gabrielsch](https://avatars.githubusercontent.com/u/1733354?v=4)](https://github.com/gabrielsch "gabrielsch (1 commits)")[![GaspariLab](https://avatars.githubusercontent.com/u/22072806?v=4)](https://github.com/GaspariLab "GaspariLab (1 commits)")[![bit4bit](https://avatars.githubusercontent.com/u/1474826?v=4)](https://github.com/bit4bit "bit4bit (1 commits)")[![acasar](https://avatars.githubusercontent.com/u/6329543?v=4)](https://github.com/acasar "acasar (1 commits)")

---

Tags

searchfulltextteamtnttntsearch

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/woodfish-tntsearch-chinese/health.svg)

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

###  Alternatives

[teamtnt/tntsearch

A fully featured full text search engine written in PHP

3.2k3.1M29](/packages/teamtnt-tntsearch)[teamtnt/laravel-scout-tntsearch-driver

Driver for Laravel Scout search package based on https://github.com/teamtnt/tntsearch

1.1k2.6M34](/packages/teamtnt-laravel-scout-tntsearch-driver)[vanry/laravel-scout-tntsearch

包含中文分词的 Laravel Scout TNTSearch 驱动，支持 scws, phpanalysis 和 jieba 分词。

17211.8k1](/packages/vanry-laravel-scout-tntsearch)[blomstra/search

Replaces Flarum search with one powered by an elastic search server.

125.1k](/packages/blomstra-search)

PHPackages © 2026

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