Searus
A flexible, multi-modal search engine library for Rust.
Overview
Searus is a powerful search engine library that provides multiple search strategies out of the box:
- Semantic Search - BM25-based text search with configurable field rules
- Tag-based Search - Exact and fuzzy tag matching
- Fuzzy Search - String similarity matching using Jaro-Winkler distance
- Vector Search - Nearest neighbor search with embeddings (via index adapters)
- Multi-modal Search - Combine multiple search strategies with weighted scoring
Features
- 🚀 Fast and Lightweight - Zero-cost abstractions with minimal dependencies
- 🔧 Flexible Configuration - Fine-tune search behavior with semantic rules
- 🎯 Multi-Strategy - Combine different search methods with custom weights
- 📊 Score Transparency - Detailed per-field scores and match explanations
- 🔌 Pluggable Storage - Bring your own index with the
IndexAdaptertrait - 🎨 Type-Safe - Generic over your document types with
serdesupport
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
Quick Start
use *;
use SemanticSearch;
use ;
Search Strategies
Semantic Search
BM25-based text search with configurable field rules and matching strategies:
use *;
use SemanticSearch;
let rules = builder
.field
.field
.field
.build;
let searcher = new;
Matching Strategies:
Matcher::BM25- Full BM25 scoring with IDFMatcher::Tokenized- Simple term frequency matchingMatcher::Exact- Case-insensitive exact string matchingMatcher::Fuzzy- Delegated toFuzzySearch
Tag-based Search
Match documents by tags with configurable field names:
use TaggedSearch;
// Default field name is "tags"
let tag_searcher = new;
// Or specify a custom field
let tag_searcher = with_field;
let query = builder
.tags
.build;
Fuzzy Search
String similarity matching using Jaro-Winkler distance:
use FuzzySearch;
let fuzzy_searcher = new
.with_threshold; // Minimum similarity: 0.0 to 1.0
let query = builder
.text // Will match "programming"
.build;
Multi-Strategy Search
Combine multiple searchers with custom weights:
use *;
use ;
let semantic_rules = builder
.field
.field
.build;
let engine = builder
.with
.with
.with
.build;
let query = builder
.text
.tags
.options
.build;
Index Adapters
Searus supports pluggable storage backends through the IndexAdapter trait:
use ;
// Built-in in-memory index
let mut index: = new;
index.put?;
// Find nearest neighbors
let neighbors = index.knn;
Implement IndexAdapter for your own storage backend (e.g., PostgreSQL, Redis, Qdrant).
Embeddings
Searus provides traits for embedding providers:
use ;
// Built-in stub embedder for testing
let embedder = new; // 384-dimensional vectors
let embedding = embedder.embed?;
// Implement TextEmbedder for your own provider (OpenAI, Cohere, local models, etc.)
Query Options
Fine-tune your search with query options:
let query = builder
.text
.tags
.options
.build;
Score Transparency
Searus provides detailed scoring information:
for result in results
Examples
Run the included examples:
# Basic semantic search
# Multi-strategy search
Architecture
searus/
├── types.rs # Core types (Query, SearusMatch, SearchOptions)
├── searcher.rs # Searcher trait
├── engine.rs # SearusEngine (orchestrates multiple searchers)
├── rules.rs # Semantic rules DSL
├── filter.rs # Filter expressions (future)
├── embeddings/ # Embedding provider traits
│ └── mod.rs
├── index/ # Storage adapters
│ ├── adapter.rs # IndexAdapter trait
│ └── memory.rs # In-memory implementation
└── searchers/ # Search implementations
├── tokenizer.rs # Text tokenization
├── bm25.rs # BM25 scorer
├── semantic.rs # Semantic search
├── tagged.rs # Tag search
└── fuzzy.rs # Fuzzy search
Roadmap
- Filter expressions (range queries, boolean logic)
- Geospatial search
- Image search with embeddings
- Persistent index adapters (PostgreSQL, Redis)
- Query DSL improvements
- Performance benchmarks
- More tokenization strategies
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- BM25 implementation inspired by search engine research
- Fuzzy matching powered by the excellent strsim crate
- Text tokenization using unicode-segmentation