Indexing¶
While Bundlebase can query any attached data, the base formats are not always the most efficient to query.
Creating indexes on columns you frequently filter on will allow for faster query execution.
Column Indexes¶
Column indexes accelerate exact-match lookups and range queries. Use create_index() with index_type="column".
Note
Until you commit, the index will not be used when the bundle is reopened.
Text Indexes¶
Text indexes enable full-text search with BM25 ranking. Use create_index() with index_type="text" and one or more columns. If no name is provided, indexes are auto-named as idx_{columns}.
# Single-column text index (auto-named "idx_description")
await bundle.create_index("description", "text")
# Multi-column text index (auto-named "idx_title_description")
await bundle.create_index(["title", "description"], "text")
# With explicit name and tokenizer
await bundle.create_index("content", "text", name="content_search", args={"tokenizer": "en_stem"})
For more details on querying and tokenizers, see Text Search.
Drop Index¶
Remove an index from a column.
Rebuild Index¶
Rebuild an existing index on a column. Useful if the index has become stale or corrupted.
Reindex¶
Create index files for any blocks that are missing them. This checks existing indexes and avoids redundant work.