Orama Core Client for Rust
A comprehensive Rust client for Orama Core and Orama Cloud.
Installation
Add this to your Cargo.toml:
[]
= "1.2.0"
= { = "1.0", = ["full"] }
= { = "1.0", = ["derive"] }
Quick Start
use ;
use ;
async
Core Concepts
Collections and Documents
Collections are containers for your documents. Each collection can have multiple indexes for different types of searches:
use ;
// Create an index
let create_params = CreateIndexParams ;
client.index.create.await?;
// Insert documents
let index = client.index.set;
index.insert_documents.await?;
Search Modes
The client supports three search modes:
- Fulltext: Traditional keyword-based search
- Vector: Semantic search using embeddings
- Hybrid: Combines both approaches for best results
use ;
// Vector search for semantic similarity
let vector_search = new
.with_mode
.with_limit;
// Hybrid search for comprehensive results
let hybrid_search = new
.with_mode
.with_threshold;
AI-Powered Features
Create AI sessions for natural language interactions:
use ;
use ;
// Create an AI session
let session_config = new
.with_llm_config;
let ai_session = client.ai.create_ai_session.await?;
// Get an AI-powered answer
let answer_config = new
.with_max_documents;
let answer = ai_session.answer.await?;
println!;
Streaming Responses
For real-time AI interactions, use streaming:
use StreamExt;
let stream_config = new;
let mut answer_stream = ai_session.answer_stream.await?;
while let Some = answer_stream.next.await
Authentication
The client supports two authentication methods:
API Key Authentication
For regular API keys:
let config = new;
JWT Authentication
For private API keys (starting with "p_"):
let config = new
.with_auth_jwt_url;
Cloud Integration
For Orama Cloud projects:
use ;
let cloud_config = new;
let cloud_client = new.await?;
// Cloud-specific search with datasources
let search_params = new;
let results = cloud_client..await?;
Collection Management
Create and manage collections programmatically:
use ;
use ;
let manager_config = OramaCoreManagerConfig ;
let manager = new.await?;
// Create a new collection
let collection_params = new
.with_description
.with_language
.with_embeddings_model;
let new_collection = manager.collection.create.await?;
Advanced Features
System Prompts
Manage AI system prompts:
// Get all system prompts
let prompts = client.system_prompts.get_all.await?;
// Get a specific prompt
let prompt = client.system_prompts.get.await?;
Tools Integration
Execute custom tools:
use ExecuteToolsBody;
let tools_body = ExecuteToolsBody ;
let result = client.tools..await?;
Hooks Management
Manage collection hooks:
use AddHookConfig;
use Hook;
let hook_config = AddHookConfig ;
let hook_response = client.hooks.insert.await?;
Examples
The repository includes comprehensive examples:
- basic_search.rs - Simple search operations
- document_management.rs - CRUD operations
- ai_session.rs - AI-powered features and streaming
- server_app.rs - Complete application example
Run an example:
Error Handling
The client provides detailed error types:
use ;
match client.search.await
Configuration
Environment Variables
You can configure the client using environment variables:
Custom Cluster Configuration
For custom deployments:
use ClusterConfig;
let config = new
.with_cluster;
Performance
The client is designed for high-performance applications:
- Connection Pooling: Reuses HTTP connections
- Async Operations: Non-blocking I/O with Tokio
- Concurrent Requests: Execute multiple operations simultaneously
- Streaming: Real-time data processing
- Type Safety: Zero-cost abstractions with compile-time guarantees
Testing
Run the test suite:
# Run all tests
# Run with output
# Run specific test
Contributing
Contributions are welcome! Please read our contributing guidelines and submit pull requests to the main repository.
Support
- Documentation: docs.rs/oramacore-client
- Issues: GitHub Issues
- Orama Documentation: docs.orama.com