Expand description
Indexing support for optimized querying.
This module provides indexing capabilities to accelerate document queries. Indexes map field values to document IDs, enabling fast lookups and range scans.
§Index Types
- Unique Index: Ensures field values are unique across all documents
- Non-Unique Index: Allows duplicate field values, maps to multiple documents
- Text Index: Full-text search index for substring and text matching
- Compound Index: Index on multiple fields for multi-field queries
§Creating Indexes
ⓘ
use nitrite::index::unique_index;
let collection = db.collection("users")?;
collection.create_index(vec!["email"], &unique_index())?;
collection.create_index(vec!["name", "age"], &non_unique_index())?;§Index Management
- Automatic indexing: Indexes are automatically used when applicable
- Index hints: Filters support specifying preferred indexes
- Index rebuilding: Rebuild corrupted or fragmented indexes
- Index dropping: Remove indexes to save space
§Performance Considerations
- Indexes speed up
find()and filtering operations - Indexes slow down insert/update/delete operations (index maintenance cost)
- Create indexes on frequently queried fields
- Unique indexes prevent duplicate values automatically
Modules§
Structs§
- InMemory
Index MapInner - Index
Descriptor - Describes the configuration of an index on a collection.
- Index
Descriptor Inner - Internal representation of index descriptor configuration.
- Index
Map - Provides efficient key-value access for index data with navigable operations.
- Index
MapIterator - Iterator over IndexMap entries with bidirectional navigation support.
- Index
Options - Specifies configuration options for creating database indexes.
- Nitrite
Indexer - Wrapper for index implementation providers with thread-safe reference counting.
Traits§
- Nitrite
Indexer Provider - Provider trait for index implementation strategies.
Functions§
- full_
text_ index - Creates IndexOptions for a full-text search index.
- non_
unique_ index - Creates IndexOptions for a non-unique index.
- unique_
index - Creates IndexOptions for a unique index.