- What is vanry/laravel-scout-tntsearch and when should I use it?
- It is a Laravel Scout driver backed by TNTSearch that gives Eloquent models local, file-based full-text search without running Meilisearch, Algolia, or Elasticsearch. You add the Searchable trait to your models and Scout keeps the index in sync as records are saved and deleted. It is a good fit for single-server apps that want fast search with zero external infrastructure, and it adds Chinese word segmentation through scws, phpanalysis, and jieba. If you need a distributed, multi-node search cluster, a hosted engine is usually the better choice.
- How do I install and configure laravel-scout-tntsearch?
- Install laravel/scout and this driver with Composer, then publish the package and Scout configuration files so you can edit them. Set the Scout driver to tntsearch in config/scout.php or via the SCOUT_DRIVER environment variable, and make sure the index storage path is writable. Add the Searchable trait to each model you want indexed and run scout:import to build the initial index. Always confirm the exact constraint and config keys against the README and the published config for your installed version.
- How do I enable Chinese word segmentation with jieba, scws, or phpanalysis?
- The package ships tokenizer integrations for scws, phpanalysis, and jieba, selected through the tokenizer setting in the published config. Each one has its own dependency story: scws typically needs the PECL scws extension, phpanalysis is pure PHP, and jieba requires its own PHP binding or dictionary files. Pick the tokenizer that matches what you can install on your servers, then rebuild the index so documents are segmented the same way at index and query time. Changing tokenizers after launch almost always requires a full reindex.
- Which Laravel and Scout versions does this driver support?
- Version 2.4.0 widened the Scout compatibility window to include Scout 9.0, which places the package in the Laravel 9/10 generation rather than only the newest majors. That is a constraint-unlock release, not a feature release, so the search behaviour itself should be unchanged. Check composer.json for the exact Scout constraint and the PHP floor, and run composer why-not in a branch of your application to confirm it actually resolves. If your app is on a newer Laravel major, verify resolution before planning any work.
- Does it support fuzzy matching and boolean queries?
- Yes. TNTSearch supports fuzzy matching so typos and near-miss spellings still return results, and it supports boolean operators so you can require, exclude, or combine terms in a query. The driver exposes that syntax through Scout's normal search entry points, so you pass the operators directly in the search string or query builder calls. Fuzzy matching is useful for user-facing search boxes, while boolean queries suit admin filters and precise internal lookups.
- What is geo search and how do I use it with this package?
- Geo search lets you filter and sort results by distance from a coordinate, which is useful for store locators, nearby listings, or delivery zones. It works on top of the TNTSearch index, so the latitude and longitude values need to be present in the indexed documents. You enable it by storing those fields on the model's searchable array and applying the geo options in your query. Check the README for the exact option names, since the API surface can change between releases.
- How does indexing and model syncing work with this driver?
- Scout observes model events, so creating, updating, and deleting a record queues or performs the matching index change automatically once the Searchable trait is in place. Bulk imports go through scout:import, which chunks records and is much faster than saving them one at a time. Because the index is a local file, writes can be slower on large imports and queue workers should be running in production. Reindex after any upgrade or tokenizer change rather than assuming the existing file is still valid.
- Where is the TNTSearch index stored and what should I watch in production?
- The index is a SQLite file written to a configured storage path, so that directory must be writable by PHP and by any queue workers that touch it. This design assumes a single shared filesystem: multiple app servers or ephemeral containers will each end up with their own divergent index unless you mount shared storage. Watch memory limits and execution time on large imports, and plan for rebuild time if the index becomes corrupted. For horizontally scaled deployments, an external search engine is usually a better fit.
- Can I plug in my own custom tokenizer?
- Yes, the driver is built to accept custom tokenizers, and the bundled scws, phpanalysis, and jieba integrations are essentially reference implementations. You implement the tokenizer contract your package version expects and reference your class in the published config. The important rule is that indexing and querying must use the same tokenizer, otherwise searches will silently miss matches. Reindex every time you swap or change a tokenizer.
- How does this compare to Meilisearch or Algolia, and is it still maintained?
- The tradeoff is infrastructure versus scale: TNTSearch runs entirely inside your app with no extra service, while Meilisearch and Algolia offer replication, typo tolerance tuning, and managed scaling. This driver is the practical choice for a single-server Laravel app, particularly one that needs Chinese segmentation out of the box. Maintenance appears active, with 2.4.0 widening Scout support, but you should verify the CI matrix actually covers the Scout version you run. Pin the version, check the release cadence, and keep a reindex step in your deploy pipeline as insurance.