Core concepts

Understanding Indexing

Think of a thick book you're trying to navigate. If you're looking for mentions of a topic like quantum mechanics, but the book doesn't have an index, you'd need to flip through every page — and that's not fun or fast. However, if there's a handy index at the back, you can quickly jump to every spot where quantum mechanics shows up. That's the magic of an index. It tells you where things are without making you search everywhere.

Search engines use a similar idea to look through all the information they have. Here's why they use an index:

  1. Speed: With an index, a search engine can jump right to the data it needs. Without one, it's like reading a book from cover to cover for every single question you have.

  2. Relevance & Ranking: An index doesn't just tell a search engine where words are; it can also say which ones show up a lot or in important places. This helps the search engine decide which results are the most useful.

  3. Complex Queries: If you're trying to make a fancy or specific search, an index helps the search engine understand and find what you're looking for without getting overwhelmed.

  4. Saving Space: While indexes do take up some room, they're like a condensed version of the main content. It's often more space-saving to look through an index than to rummage through all the raw info over and over.

So, before a search engine can quickly answer questions, it has to create an index of its info. This is a bit like making a roadmap that says where everything is.

Now, there's a special kind of index called an "inverted index". And that's where TNTSearch shines. By default, TNTSearch uses an SQLite database to keep this index. But it's also flexible. If you prefer, you can switch to storing your index in a Redis database. Here's a quick example of how you can set that up:

    $config = [
        'engine'     => 'TeamTNT\TNTSearch\Engines\RedisEngine',
        'redis_host' => '127.0.0.1',
        'redis_port' => '6379',
    ];
Previous
Installation