nitrite_tantivy_fts

Crates.ionitrite_tantivy_fts
lib.rsnitrite_tantivy_fts
version0.1.0
created_at2025-12-16 19:47:31.858116+00
updated_at2025-12-16 19:47:31.858116+00
descriptionFull-text search support for Nitrite database using Tantivy
homepage
repositoryhttps://github.com/nitrite/nitrite-rust
max_upload_size
id1988529
size141,853
Anindya Chatterjee (anidotnet)

documentation

README

Nitrite Tantivy FTS

Full-text search module for Nitrite using Tantivy.

Features

  • Full-Text Indexing - Tokenized text search with Tantivy
  • Term Matching - Search for individual terms in text fields
  • Index Management - Create and drop FTS indexes

Usage

Loading the Module

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

Creating an FTS Index

use nitrite_tantivy_fts::fts_index;

let collection = db.collection("articles").unwrap();
collection.create_index(vec!["content"], &fts_index()).unwrap();

Inserting Documents

use nitrite::doc;

let doc = doc! {
    title: "Hello World",
    content: "A quick brown fox jumps over the lazy dog"
};
collection.insert(doc).unwrap();

Searching

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

Dropping an FTS Index

collection.drop_index(vec!["content"]).unwrap();

Checking Index Existence

let has_index = collection.has_index(vec!["content"]).unwrap();

Integration with Fjall

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

License

Apache License 2.0

Commit count: 0

cargo fmt