postings
Inverted-index postings lists with segment-style updates.
Supports u32 term frequencies (classical IR) and f32 weights
(SPLADE / learned-sparse retrieval).
Data Model & Invariants
- Doc IDs:
u32. Must be dense/contiguous for optimal compression. - Ordering: Postings lists are always sorted by Doc ID.
- Updates: Segment-based. Deletions are tombstones; updates are delete+add.
- Storage: In-memory by default. Persistence via
durability(optional).
Usage
[]
= "0.2"
Example (index + candidates):
use ;
let mut idx = new;
idx.add_document
.unwrap;
idx.add_document
.unwrap;
// Conjunctive (AND) candidates.
assert_eq!;
let cfg = default;
let plan = idx.plan_candidates;
assert!;
Example (learned-sparse top-k):
use PostingsIndex;
let mut idx: = new;
idx.add_weighted_document
.unwrap;
idx.add_weighted_document
.unwrap;
let ranking = idx.top_k_weighted;
assert_eq!;
Examples
Runnable examples live in examples/:
durable_roundtrippairspostingswithdurabilityto build a crash-recoverable inverted index: update events go to a record log, snapshots to a checkpoint, and the index rebuilds from both, the persistence pattern a search engine needs to survive restarts.
Features
postings/serde: enable serde for the in-memory structures.postings/persistence: enable save/load helpers viadurability+postcard.postings/sbits: enable succinct monotone sequences (Elias–Fano) underpostings::codec::ef.postings/positional: enable positional postings (postings::positional::PosingsIndex).postings/cnk-compression: enable optional compressed-candidate helpers underpostings::positional::cnk_candidates.postings/raw-segment: enable the experimental byte- and file-backed raw segment reader.
Optional: positional postings
Enable positional postings behind a feature flag:
[]
= { = "0.2", = ["positional"] }
Then use postings::positional::PosingsIndex for phrase/proximity evaluation.
Development