text-search

Crates.iotext-search
lib.rstext-search
version0.1.0
created_at2025-06-06 14:27:42.618531+00
updated_at2025-06-06 14:27:42.618531+00
descriptionA simple easy to use plug and play wrapper around tantivy for simple search scenarios.
homepagehttps://github.com/Salman-Sali/text-search
repository
max_upload_size
id1703093
size41,501
(Salman-Sali)

documentation

README

A plug and play wrapper around tantivy.

Diesel is to SQL as text-search is to tantivy.

UNDER DEVELOPMENT

Currently will only function if:

  • all fields are "stored"
  • fields must be String or i32
  • refer example
use text_search::{Indexer, Indexed};

#[derive(Indexed)]
pub struct Book {
    //default is #[text_search(not_indexed, stored)]

    //id behaves like #[text_search(indexed, stored)]
    #[text_search(id)]
    pub id: i32,
    #[text_search(indexed_text, stored)]
    pub name: String,
    #[text_search(indexed_text, stored)]
    pub author: String,
    #[text_search(indexed_text, stored)]
    pub description: String,
    pub published_on: i32
}

fn main() {
  let mut indexer = Indexer::<Book>::new(Path::new("/path/to/your/dir"));
  let books = Book::get_sample_books();
  
  for book in books {
      indexer.index(book);        
  }
  indexer.commit();

  let basic_search_result: Vec<Book> = indexer.search("name", "Rust", 10);

  let fuzzy_search_result: Vec<Book> = indexer.fuzzy_search("name", "Rosty", 10);

  let regex_search_result: Vec<Book> = indexer.regex_query("name", "rustacea.*", 10);
}
Commit count: 0

cargo fmt