| Crates.io | nitrite_tantivy_fts |
| lib.rs | nitrite_tantivy_fts |
| version | 0.1.0 |
| created_at | 2025-12-16 19:47:31.858116+00 |
| updated_at | 2025-12-16 19:47:31.858116+00 |
| description | Full-text search support for Nitrite database using Tantivy |
| homepage | |
| repository | https://github.com/nitrite/nitrite-rust |
| max_upload_size | |
| id | 1988529 |
| size | 141,853 |
Full-text search module for Nitrite using Tantivy.
use nitrite::nitrite::Nitrite;
use nitrite_tantivy_fts::TantivyFtsModule;
let db = Nitrite::builder()
.load_module(TantivyFtsModule::default())
.open_or_create(None, None)
.expect("Failed to create database");
use nitrite_tantivy_fts::fts_index;
let collection = db.collection("articles").unwrap();
collection.create_index(vec!["content"], &fts_index()).unwrap();
use nitrite::doc;
let doc = doc! {
title: "Hello World",
content: "A quick brown fox jumps over the lazy dog"
};
collection.insert(doc).unwrap();
use nitrite_tantivy_fts::fts_field;
// Search for a term in the indexed field
let filter = fts_field("content").matches("fox");
let cursor = collection.find(filter).unwrap();
collection.drop_index(vec!["content"]).unwrap();
let has_index = collection.has_index(vec!["content"]).unwrap();
For persistent FTS with Fjall storage:
use nitrite::nitrite::Nitrite;
use nitrite_fjall_adapter::FjallModule;
use nitrite_tantivy_fts::TantivyFtsModule;
let storage = FjallModule::with_config()
.db_path("/path/to/database")
.build();
let db = Nitrite::builder()
.load_module(storage)
.load_module(TantivyFtsModule::default())
.open_or_create(None, None)
.expect("Failed to create database");
Apache License 2.0