Skip to main content

Module index

Module index 

Source
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§

index_meta
index_scanner
non_unique_indexer
text
text_indexer
unique_indexer

Structs§

InMemoryIndexMapInner
IndexDescriptor
Describes the configuration of an index on a collection.
IndexDescriptorInner
Internal representation of index descriptor configuration.
IndexMap
Provides efficient key-value access for index data with navigable operations.
IndexMapIterator
Iterator over IndexMap entries with bidirectional navigation support.
IndexOptions
Specifies configuration options for creating database indexes.
NitriteIndexer
Wrapper for index implementation providers with thread-safe reference counting.

Traits§

NitriteIndexerProvider
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.