xapian-rusty
xapian-rusty is Rust bindings for the Xapian search engine library. This library gives you a safe and easy way to add full-text search to your Rust applications.
🚀 Features
- ✅ Full support for main Xapian functions
- ✅ Safe memory management with Rust ownership
- ✅ Easy API for indexing and searching documents
- ✅ Support for different data types (text, numbers, dates)
- ✅ Advanced query and sorting options
- ✅ Stemming and language support
📋 Requirements
System Requirements
- Rust: edition 2024 or newer
- C++ compiler: GCC 4.9+ or Clang 3.4+
- CMake: 3.10 or newer (to build Xapian)
- Operating System: Linux, macOS, Windows (WSL)
Dependencies
- Xapian 1.2.25 (install instructions below)
🛠️ Installation
Step 1: Install Xapian
-
Download Xapian 1.2.25 from the official website:
-
Apply patches (if using patches from repository):
# Copy files from xapian-patch/ to Xapian directories -
Build Xapian:
-
Rename the library (for xapian-rusty compatibility):
# or copy:
Step 2: Install xapian-rusty
Add to your Cargo.toml:
[]
= "0.0.56"
Or install from local repository:
📖 Usage Examples
Create Index and Add Documents
use *;
Search Documents
use *;
Advanced Search with Sorting
use *;
🏗️ Project Structure
xapian-rusty/
├── src/
│ └── lib.rs # Main library with Rust API
├── include/
│ └── xapian/ # Xapian header files
├── xapian-patch/ # Patches for Xapian
│ ├── api/
│ └── include/
├── build.rs # Build script
├── xapian-bind.cc # C++ bindings
├── xapian-bind.h # Binding header files
└── Cargo.toml # Rust configuration
🔧 Troubleshooting
Build Errors
Problem: error: could not find native library xapianm
# Solution: make sure libxapianm.so is created
# Add library path:
Problem: Compiler warnings
# Solution: set environment variables
CC=gcc CXX=g++
Problem: C++ build errors
# Make sure required tools are installed:
Runtime Errors
Problem: DatabaseError when opening database
- Check file permissions for database directory
- Make sure database path is correct
- Check if database is not corrupted
Problem: Text encoding issues
- Make sure all text is in UTF-8
- Use correct language stemmers
📚 API Documentation
Main Types
Database- database for readingWritableDatabase- database for writingDocument- document for indexingQuery- search queryTermGenerator- term generator for indexingQueryParser- search query parserEnquire- interface for running queriesMSet- search results
Error Types
XError::Xapian(code)- Xapian errors with codeXError::Io(error)- input/output errors
🤝 Contributing
We welcome contributions to this project! Please:
- Fork the repository
- Create a branch for your changes (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Create a Pull Request
📄 License
This project is licensed under the MIT License. See the LICENSE file for details.
👥 Authors
- Valeriy Bushenev - ValeriyBushenev@gmail.com
- David Tolnay - dtolnay@gmail.com
🔗 Useful Links
Note: This project is under active development. The API may change between versions.