strapi-plugin-tantivy
v1.0.3
Published
Tantivy Search Plugin for Strapi
Readme
Strapi Plugin Tantivy bridges the gap between Strapi and Tantivy (via node-tantivy-binding), providing an incredibly fast, highly scalable, full-text search engine natively integrated into your Strapi backend.
Forget complex external setups like Elasticsearch or Algolia—get lightning-fast search capabilities directly within your Node.js infrastructure.
✨ Features
- ⚡️ Blazing Fast: Powered by Rust-based Tantivy, indexing and querying are orders of magnitude faster than traditional SQL wildcard searches.
- 🔄 Auto-Sync: Automatically intercepts and indexes content creation, updates, and deletions in Strapi.
- 🗄 Zero External Dependencies: Runs entirely within your Node.js process using native bindings. No need for a separate search server.
- ⚙️ Configurable: Choose exactly which collections to index.
- 🚀 Redis Cache Ready: Built-in support for caching queries in Redis for even faster subsequent reads.
- 🛡 Admin Dashboard: Easily view and manage the indexing status directly from your Strapi Admin UI.
📦 Installation
To install this plugin, run the following command in your Strapi project:
npm install strapi-plugin-tantivy
# or
yarn add strapi-plugin-tantivy🚀 Configuration
Enable and configure the plugin in your config/plugins.js (or config/plugins.ts) file.
module.exports = ({ env }) => ({
// ... your other plugins
'strapi-plugin-tantivy': {
enabled: true,
config: {
// Enable or disable Redis caching for search queries
redisCache: true,
// List the Content-Type UIDs of the collections you want to index
collections: [
'api::device.device',
'api::vendor.vendor',
'api::app.app',
'api::product.product'
]
}
}
});💡 How It Works
Once configured, the plugin performs the following tasks:
- Initialization: On Strapi startup, it verifies the Tantivy index directories.
- Lifecycle Hooks: It dynamically attaches to the
afterCreate,afterUpdate, andafterDeletehooks of the collections specified in your configuration. - Indexing: Any time a document is modified in Strapi, it is instantly synchronized into the local Tantivy index (stored in
temp/ordata/). - Querying: You can hit the search endpoints via the plugin's exposed controllers (e.g.,
/api/search) to retrieve fast, semantically ranked search results.
🛠 Usage in API
You can trigger a search via the Strapi API by leveraging the plugin's services. Assuming you expose a custom controller:
const { data } = await strapi.plugin('strapi-plugin-tantivy').service('tantivy').search(query, collectionUid);(Note: Ensure you have built out a custom route/controller or are using the one exposed natively by the plugin!)
🤝 Contributing
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
- Clone this repository.
- Run
npm install. - Create your feature branch (
git checkout -b feature/amazing-feature). - Commit your changes (
git commit -m 'Add some amazing feature'). - Push to the branch (
git push origin feature/amazing-feature). - Open a Pull Request.
📝 License
This project is licensed under the MIT License.
