Simplify Search Integration with TNTSearch

TNTSearch is a powerful and efficient full-text search engine library designed for use in applications and websites written entirely in PHP.

search.php
composer.json
use TeamTNT\TNTSearch\TNTSearch;
$tnt = new TNTSearch;
$tnt->loadConfig($config);
$indexer = $tnt->createIndex('articles.index');
$indexer->query('SELECT id, article FROM articles;');
$indexer->run();

Introduction

Welcome to TNTSearch! 🚀

Welcome to the official documentation of TNTSearch, a powerful and flexible search engine crafted to provide accurate and fast full-text search capabilities. Whether you're a beginner just getting started with search functionalities or an experienced developer looking for advanced features, you've come to the right place.

Being crafted entirely in PHP, TNTSearch provides PHP developers with a native solution that integrates flawlessly into their projects.It is a powerful and efficient full-text search engine designed to enhance your projects with lightning-fast and precise search capabilities. It empowers developers to effortlessly implement advanced search functionality, making it easier for users to find exactly what they're looking for. With features that span from indexing and querying to ranking and highlighting, TNTSearch equips you with the tools you need to build remarkable search experiences.

Let's embark on this exploration of TNTSearch's capabilities, and discover how it can revolutionize the way you approach search in your applications.

Installation

Step-by-step guides to setting up your system and installing the library.

Architecture guide

Learn how the internals work and contribute.

Plugins

Extend the library with third-party plugins or write your own.

API reference

Learn to easily customize and modify your app's visual design to fit your brand.


Quick start

Before you begin, make sure you have PHP and Composer installed on your system. Also make sure your server meets the following requirements:

  • PHP >= 7.1
  • PDO PHP Extension
  • SQLite PHP Extension
  • mbstring PHP Extension

Installation

TNTSearch is a composer package and is installed using this command:

composer require teamtnt/tntsearch

Creating an index

Creating an index with TNTSearch is a fundamental step that enables efficient full-text searching in your application.

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->run();

After you've successfully created an index using TNTSearch, the next step is to perform searches and retrieve relevant results. TNTSearch offers a variety of search methods and options to help you find the information you need efficiently.

Here's how to perform a basic search using TNTSearch:

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

You should know!

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);


Getting help

For bugs, feature requests, or specific technical problems, please open an issue on the TNTSearch GitHub repository. Before opening a new issue, we recommend you:

  • Search through existing issues to see if someone else has reported the same problem or had the same question.
  • Provide as much detail as possible when describing your issue, including error messages, logs, and steps to reproduce (if applicable).
  • Tag your issue appropriately (e.g., bug, enhancement, question).

Stack Overflow

If you have general questions or need help with implementation details, you can also ask the community on Stack Overflow. Remember to:

  • Use the tag tntsearch when posting your question to ensure it reaches the right audience.
  • Be clear in your question's title and body. Provide all necessary details and describe what you've tried so far.
  • Engage with those who answer, whether it's to thank them or to ask for further clarification.

Ask a Question on Stack Overflow

Always keep in mind to be respectful and patient when seeking help. The community is here to assist you, and providing clear, detailed information will facilitate faster and more accurate responses.