nitrite/index/mod.rs
1//! Indexing support for optimized querying.
2//!
3//! This module provides indexing capabilities to accelerate document queries.
4//! Indexes map field values to document IDs, enabling fast lookups and range scans.
5//!
6//! # Index Types
7//!
8//! - **Unique Index**: Ensures field values are unique across all documents
9//! - **Non-Unique Index**: Allows duplicate field values, maps to multiple documents
10//! - **Text Index**: Full-text search index for substring and text matching
11//! - **Compound Index**: Index on multiple fields for multi-field queries
12//!
13//! # Creating Indexes
14//!
15//! ```rust,ignore
16//! use nitrite::index::unique_index;
17//!
18//! let collection = db.collection("users")?;
19//! collection.create_index(vec!["email"], &unique_index())?;
20//! collection.create_index(vec!["name", "age"], &non_unique_index())?;
21//! ```
22//!
23//! # Index Management
24//!
25//! - **Automatic indexing**: Indexes are automatically used when applicable
26//! - **Index hints**: Filters support specifying preferred indexes
27//! - **Index rebuilding**: Rebuild corrupted or fragmented indexes
28//! - **Index dropping**: Remove indexes to save space
29//!
30//! # Performance Considerations
31//!
32//! - Indexes speed up `find()` and filtering operations
33//! - Indexes slow down insert/update/delete operations (index maintenance cost)
34//! - Create indexes on frequently queried fields
35//! - Unique indexes prevent duplicate values automatically
36
37mod descriptor;
38mod nitrite_indexer;
39mod index_map;
40pub mod index_meta;
41mod nitrite_index;
42mod compound_index;
43pub mod text;
44pub mod index_scanner;
45mod options;
46mod text_index;
47mod simple_index;
48pub mod text_indexer;
49pub mod unique_indexer;
50pub mod non_unique_indexer;
51
52pub use descriptor::*;
53pub use index_map::*;
54pub use nitrite_indexer::*;
55pub use options::*;