Skip to content
You are viewing the corvid 0.2.1 release snapshot — frozen at the 0.2.1 engine release.Current documentation

Text indexes

# use corvid::{Db};
# let db = Db::open_in_memory()?; let c = db.collection("docs");
c.create_text_index("body")?; // in-RAM postings
c.create_text_index_ondisk("body")?; // on-disk postings
# Ok::<(), corvid::Error>(())

Both are incremental inverted indexes storing per-term postings with positional information, updated transactionally with every write. Both back text_search (BM25), phrase_search (in-order positional matching), and the query builder’s .text(...) source identically — a query touches only its query terms’ postings instead of rescanning the corpus.

create_text_indexcreate_text_index_ondisk
Postings livein memoryas storage records
Memoryproportional to corpusbounded by the operation
Open costrebuilt lazily on first useready immediately, no rebuild
Persistsdefinition persists; postings rebuilddefinition + state persist
Whenup to ~100k–1M docsbeyond, or tight-memory deployments

Non-text values in the indexed field are excluded from postings; text mutations keep search correct on every path (indexed and scan arms are conformance-pinned to match — see the construct reference).

On the pinned 2k-doc benchmark corpus, BM25 goes ~8.0 ms (exact scan) → ~0.49 ms (indexed) — the index also serves phrase queries’ positional checks. Single-source ranked builder queries are bounded: no corpus materialization. See performance.

The index and the query share one analyzer (lowercase, English stop words, conservative plural stemmer, CJK bigrams) — see tokenization. Consequence for upgrades: when the analyzer changes between engine versions (the CJK bigram change is the example), re-create existing text indexes so postings match the new tokenizer.

Next: geo indexes.