Expand description
High-level client API for document indexing and retrieval.
This module provides the main entry point for using vectorless:
Engine— The main client for indexing and querying documentsEngineBuilder— Builder pattern for client configurationIndexContext— Unified input for document indexingSession— Multi-document session management
§Architecture
The client module is organized into specialized sub-modules:
client/
├── mod.rs → Re-exports and documentation
├── engine.rs → Main orchestrator
├── builder.rs → Builder pattern
├── index_context.rs → Index input types
├── types.rs → Public API types
├── context.rs → Request context and configuration
├── session.rs → Session management
├── indexer.rs → Document indexing operations
├── retriever.rs → Query and retrieval operations
├── workspace.rs → Workspace CRUD operations
└── events.rs → Event system and callbacks§Quick Start
use vectorless::client::{Engine, EngineBuilder, IndexContext};
// Create a client with default settings
let client = EngineBuilder::new()
.with_workspace("./my_workspace")
.build()
.await?;
// Index a document from file
let doc_id = client.index(IndexContext::from_path("./document.md")).await?;
// Index HTML content directly
let html = "<html><body><h1>Title</h1><p>Content</p></body></html>";
let doc_id2 = client.index(
IndexContext::from_content(html, vectorless::parser::DocumentFormat::Html)
.with_name("webpage")
).await?;
// Query the document
let result = client.query(&doc_id, "What is this?").await?;
println!("{}", result.content);
// List all documents
for doc in client.list_documents().await? {
println!("{}: {}", doc.id, doc.name);
}§Session-Based Operations
For multi-document operations, use sessions:
let client = EngineBuilder::new()
.with_workspace("./workspace")
.build()
.await?;
let session = client.session().await;
// Index multiple documents
let doc1 = session.index(IndexContext::from_path("./doc1.md")).await?;
let doc2 = session.index(IndexContext::from_path("./doc2.md")).await?;
// Query across all documents
let results = session.query_all("What is the architecture?").await?;§Events and Progress
Monitor operation progress with events:
let events = EventEmitter::new()
.on_index(|e| match e {
IndexEvent::Complete { doc_id } => println!("Indexed: {}", doc_id),
_ => {}
});
let client = EngineBuilder::new()
.with_events(events)
.build()
.await?;§Features
- Document Indexing — Parse and index Markdown, PDF, and text files
- Tree-Based Structure — Documents organized as hierarchical trees
- Workspace Persistence — Save and load indexed documents
- Session Management — Multi-document operations with caching
- Event System — Progress callbacks and monitoring
Re-exports§
pub use events::AsyncEventHandler;pub use events::Event;pub use events::EventEmitter;pub use events::EventHandler;pub use events::IndexEvent;pub use events::QueryEvent;pub use events::WorkspaceEvent;
Modules§
- events
- Event system for client operations.
Structs§
- Client
Context - Request context for client operations.
- Document
Info - Document info for listing.
- Engine
- The main Engine client.
- Engine
Builder - Builder for creating a
Engineclient. - Feature
Flags - Feature flags for request.
- Index
Context - Context for document indexing operations.
- Index
Options - Options for indexing a document.
- Indexed
Document - An indexed document with its tree structure and metadata.
- Indexer
Client - Document indexing client.
- Indexer
Config - Indexer configuration.
- Node
Context - Node context information.
- Page
Content - Content for a single page.
- Query
Result - Result of a document query.
- Request
Context Config - Request-specific configuration overrides.
- Retriever
Client - Document retrieval client.
- Retriever
Client Config - Retriever configuration.
- Session
- Session for managing multiple documents.
- Session
Config - Session configuration.
- Session
Stats - Session statistics.
- Validation
Result - Document validation result.
- Workspace
Client - Workspace management client.
- Workspace
Client Config - Workspace client configuration.
- Workspace
Stats - Workspace statistics.
Enums§
- Build
Error - Error during client build.
- Client
Error - Client error types.
- Eviction
Policy - Cache eviction policy.
- Index
Mode - Document indexing behavior mode.
- Index
Source - The source of document content for indexing.
- Preload
Strategy - Document preload strategy.