PHPackages                             jaafarazizi/aseclassification - 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. jaafarazizi/aseclassification

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

jaafarazizi/aseclassification
=============================

A fully featured full text search engine written in PHP

v2.1.0(7y ago)06MITPHPPHP ~7.1CI failing

Since Apr 6Pushed 6y ago1 watchersCompare

[ Source](https://github.com/jaafarazizi/AseClassification)[ Packagist](https://packagist.org/packages/jaafarazizi/aseclassification)[ Docs](https://github.com/teamtnt/tntsearch)[ RSS](/packages/jaafarazizi-aseclassification/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (48)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 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)

TNTSearch
=========

[](#tntsearch)

TNTSearch is a fully featured full text search engine written entirely in PHP. It's simple configuration allows you to add an amazing search experience to your site in just minutes. It has also a build in geo-search and a text classifier. Other features are

- fuzzy search
- as you type functionality
- geo-search
- text-classification
- stemming
- custom tokenizers
- bm25 ranking algorithm
- boolean search
- result highlighting

We created also some demo pages that show tolerant retrieval with n-grams in action. The package has bunch of helper functions like jaro-winkler and cosine similarity for distance calculations. It supports stemming for English, Croatian, Arabic, Italian, Russian, Portuguese and Ukrainian. If the built in stemmers aren't enough, the engine lets you easily plugin any compatible snowball stemmer. Some forks of the package even support Chinese.

Unlike many other engines, the index can be easily updated without doing a reindex or using deltas.

**View** [online demo](http://tntsearch.tntstudio.us/) | **Follow us** on [Twitter](https://twitter.com/tntstudiohr), or [Facebook](https://www.facebook.com/tntstudiohr) | **Visit our sponsors**:

 [ ![](https://camo.githubusercontent.com/fc250ce491a7bd02abbcd52d00c2f5e15f081fb7b7370201854c93ceecc710d8/68747470733a2f2f6b6f69737479612e6769746875622e696f2f66696c65732f6469676974616c2d6f6365616e2d3339337836342e706e67) ](https://m.do.co/c/ddfc227b7d18)

---

Demo
----

[](#demo)

- [TV Shows Search](http://tntsearch.tntstudio.us/)
- [PHPUnit Documentatin Search](http://phpunit.tntstudio.us)
- [City Search with n-grams](http://cities.tnt.studio/)

Tutorials
---------

[](#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)
- [Did you mean functionality with Laravel Scout](http://tnt.studio/blog/did-you-mean-functionality-with-laravel-scout)

Support us on Open Collective
-----------------------------

[](#support-us-on-open-collective)

- [TNTSearch](https://opencollective.com/tntsearch)

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

[](#installation)

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

```
composer require teamtnt/tntsearch

```

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

[](#requirements)

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

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

Examples
--------

[](#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/',
    'stemmer'   => \TeamTNT\TNTSearch\Stemmer\PorterStemmer::class//optional
]);

$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 than `id` set it like:

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

### Making the primary key searchable

[](#making-the-primary-key-searchable)

By default the primary key is not searchable, if you wanna make it searchable simply run:

```
$indexer->includePrimaryKey();
```

### 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 against your application database
// 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);
```

Custom Tokenizer
----------------

[](#custom-tokenizer)

First, create your own Tokenizer class that implements TokenizerInterface:

```
use TeamTNT\TNTSearch\Support\TokenizerInterface;

class SomeTokenizer implements TokenizerInterface {

    public function tokenize($text) {
        return preg_split("/[^\p{L}\p{N}-]+/u", strtolower($text), -1, PREG_SPLIT_NO_EMPTY);
    }
}
```

The only difference here from the original is that the regex contains a dash `[^\p{L}\p{N}-]`

After you have the tokenizer ready, your `TNTIndexer` and `TNTSearch` class should consume it.

```
$someTokenizer = new SomeTokenizer;

$indexer = new TNTIndexer;
$indexer->setTokenizer($someTokenizer);
```

And in the `TNTSearch` class you do the same

```
$someTokenizer = new SomeTokenizer;

$tnt = new TNTSearch;
$tnt->setTokenizer($someTokenizer);
```

Geo Search
----------

[](#geo-search)

### Indexing

[](#indexing)

```
$candyShopIndexer = new TNTGeoIndexer;
$candyShopIndexer->loadConfig($config);
$candyShopIndexer->createIndex('candyShops.index');
$candyShopIndexer->query('SELECT id, longitude, latitude FROM candy_shops;');
$candyShopIndexer->run();
```

### Searching

[](#searching-1)

```
$currentLocation = [
    'longitude' => 11.576124,
    'latitude'  => 48.137154
];

$distance = 2; //km

$candyShopIndex = new TNTGeoSearch();
$candyShopIndex->loadConfig($config);
$candyShopIndex->selectIndex('candyShops.index');

$candyShops = $candyShopIndex->findNearest($currentLocation, $distance, 10);
```

Classification
--------------

[](#classification)

```
use TeamTNT\TNTSearch\Classifier\TNTClassifier;

$classifier = new TNTClassifier();
$classifier->learn("A great game", "Sports");
$classifier->learn("The election was over", "Not sports");
$classifier->learn("Very clean match", "Sports");
$classifier->learn("A clean but forgettable game", "Sports");

$guess = $classifier->predict("It was a close election");
var_dump($guess['label']); //returns "Not sports"
```

### Saving the classifier

[](#saving-the-classifier)

```
$classifier->save('sports.cls');
```

### Loading the classifier

[](#loading-the-classifier)

```
$classifier = new TNTClassifier();
$classifier->load('sports.cls');
```

Drivers
-------

[](#drivers)

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

PS4Ware
-------

[](#ps4ware)

You're free to use this package, but if it makes it to your production environment we would highly appreciate you sending us a PS4 game of your choise. This way you support us to further develop and add new features to this package.

Our address is: TNT Studio, Sv. Mateja 19, 10010 Zagreb, Croatia.

We'll publish all received games on our company website.

Support [![OpenCollective](https://camo.githubusercontent.com/061cbedd38b327870b53630a62bc9ae341c547b5e9fde48856f293265a224a12/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f746e747365617263682f6261636b6572732f62616467652e737667)](#backers) [![OpenCollective](https://camo.githubusercontent.com/8279728f839e0ba99372f5f57f9dd8709511bcfcae0c5e9c278c8e93b941ce3d/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f746e747365617263682f73706f6e736f72732f62616467652e737667)](#sponsors)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

[](#support--)

[![Buy Me a Coffee at ko-fi.com](https://camo.githubusercontent.com/83ee39fe9fbdf4f0aca269781d75b41ab20a65450f9255b330142b8c3da128a7/68747470733a2f2f617a3734333730322e766f2e6d7365636e642e6e65742f63646e2f6b6f6669342e706e673f763d30)](https://ko-fi.com/O4O3K2R9)

### Backers

[](#backers)

Support us with a monthly donation and help us continue our activities. \[[Become a backer](https://opencollective.com/tntsearch#backer)\]

Sponsors
--------

[](#sponsors)

Become a sponsor and get your logo on our README on Github with a link to your site. \[[Become a sponsor](https://opencollective.com/tntsearch#sponsor)\]

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.

---

From Croatia with ♥ by TNT Studio ([@tntstudiohr](https://twitter.com/tntstudiohr), [blog](https://tnt.studio))

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 84.8% 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 ~25 days

Recently: every ~67 days

Total

46

Last Release

2558d ago

Major Versions

v0.9.0 → v1.0.02017-02-07

v1.4.0 → v2.0.02019-02-11

PHP version history (2 changes)v0.1.0PHP ~5.5|~7.0

v2.0.0PHP ~7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/05b188b40dd7682756b786d84cc5ec20d0053468e596832d43d774f5aff655d6?d=identicon)[jaafarazizi](/maintainers/jaafarazizi)

---

Top Contributors

[![nticaric](https://avatars.githubusercontent.com/u/824840?v=4)](https://github.com/nticaric "nticaric (267 commits)")[![Namoshek](https://avatars.githubusercontent.com/u/8877609?v=4)](https://github.com/Namoshek "Namoshek (4 commits)")[![LucasPadilha](https://avatars.githubusercontent.com/u/6677271?v=4)](https://github.com/LucasPadilha "LucasPadilha (4 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 (4 commits)")[![Connum](https://avatars.githubusercontent.com/u/13076806?v=4)](https://github.com/Connum "Connum (3 commits)")[![marqu3s](https://avatars.githubusercontent.com/u/2284983?v=4)](https://github.com/marqu3s "marqu3s (3 commits)")[![lgXenos](https://avatars.githubusercontent.com/u/14957311?v=4)](https://github.com/lgXenos "lgXenos (3 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (2 commits)")[![flaird](https://avatars.githubusercontent.com/u/8861915?v=4)](https://github.com/flaird "flaird (2 commits)")[![GaspariLab](https://avatars.githubusercontent.com/u/22072806?v=4)](https://github.com/GaspariLab "GaspariLab (2 commits)")[![Findus23](https://avatars.githubusercontent.com/u/6266037?v=4)](https://github.com/Findus23 "Findus23 (2 commits)")[![jaafarazizi](https://avatars.githubusercontent.com/u/12953217?v=4)](https://github.com/jaafarazizi "jaafarazizi (2 commits)")[![XGhozt](https://avatars.githubusercontent.com/u/5670495?v=4)](https://github.com/XGhozt "XGhozt (1 commits)")[![acasar](https://avatars.githubusercontent.com/u/6329543?v=4)](https://github.com/acasar "acasar (1 commits)")[![bit4bit](https://avatars.githubusercontent.com/u/1474826?v=4)](https://github.com/bit4bit "bit4bit (1 commits)")[![DarkaOnLine](https://avatars.githubusercontent.com/u/1171698?v=4)](https://github.com/DarkaOnLine "DarkaOnLine (1 commits)")[![gabrielsch](https://avatars.githubusercontent.com/u/1733354?v=4)](https://github.com/gabrielsch "gabrielsch (1 commits)")[![michaeldim](https://avatars.githubusercontent.com/u/1141848?v=4)](https://github.com/michaeldim "michaeldim (1 commits)")[![michaelklopf](https://avatars.githubusercontent.com/u/2892138?v=4)](https://github.com/michaelklopf "michaelklopf (1 commits)")

---

Tags

searchfulltextfuzzy-searchteamtnttntsearchgeosearch

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[teamtnt/tntsearch

A fully featured full text search engine written in PHP

3.2k3.0M28](/packages/teamtnt-tntsearch)[teamtnt/laravel-scout-tntsearch-driver

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

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

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

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

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

114.9k](/packages/blomstra-search)

PHPackages © 2026

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