Skip to main content

Module search

Module search 

Source

Traits§

Indexer
A pluggable search index. Keyed by index (a resource’s base_path()), so one backend serves every searchable resource. Async — it does I/O, once per mutation, not per request.

Functions§

document_for
Project a stored row to the document to index: just the resource’s declared search_fields (plus nothing else — the id is carried separately). Missing fields are simply absent.
index_record
Index (or re-index) a record after a write. Best-effort: an indexing failure is logged, never propagated — a search backend hiccup must not fail the write the user asked for. The index catches up on the next write or a reindex.
indexer
The registered indexer, if any.
is_enabled
Whether search is on. Default CRUD checks this before spending a read to build a document, so an unindexed app issues exactly the queries it did before this module existed.
query_term
The q full-text term from a request query string, trimmed; None when absent or blank. The list page uses this to decide between a search and the normal paginated listing.
remove_record
Remove a record from the index after a delete. Best-effort, same rationale as index_record.
search_ids
Search an index, returning matching ids in rank order. Returns empty (never errors to the caller) so a list page renders even when the backend is down.
set_indexer
Register the global search backend. Set-once, matching the other seams.