Expand description
tinysearch - A tiny search engine for static websites
This crate provides a fast, memory-efficient search engine that can be compiled to WebAssembly for client-side search functionality on static websites.
§Library Usage
This crate can be used both as a command-line tool and as a library for programmatic access to search index generation and search functionality.
§Basic Usage
use tinysearch::{BasicPost, TinySearch, SearchIndex};
use std::collections::HashMap;
// Create posts
let posts = vec![
BasicPost {
title: "First Post".to_string(),
url: "/first".to_string(),
body: Some("This is the first post content".to_string()),
meta: HashMap::new(),
},
BasicPost {
title: "Second Post".to_string(),
url: "/second".to_string(),
body: Some("This is the second post about rust programming".to_string()),
meta: HashMap::new(),
}
];
// Build search index
let search = TinySearch::new();
let index: SearchIndex = search.build_index(&posts).expect("Failed to build index");
// Search
let results = search.search(&index, "rust", 10);
Re-exports§
pub use api::BasicPost;
pub use api::Post;
pub use api::TinySearch;
Modules§
- api
- Public API for tinysearch library
Structs§
- PostId
- Represents a post with its title, URL, and metadata
- Storage
- Storage container for serialized search index
Traits§
- Score
- Trait for scoring search terms against a filter
Functions§
- search
- Performs a search query against the provided filters
Type Aliases§
- Filter
- Type alias for the filter used in search
- Post
Filter - A post with its associated Xor filter for fast lookups
- Search
Index - A deserialized search index containing posts and their search filters