"""Select the active SearchBackend from config (SPEC ยง8.1, env SEARCH_BACKEND).""" from __future__ import annotations from app.config import get_settings from app.search.base import SearchBackend from app.search.pg import PgSearchBackend _backend: SearchBackend | None = None def get_search_backend() -> SearchBackend: """Return the process-wide SearchBackend (``pg`` in M0-M1, ``meili`` in M2).""" global _backend if _backend is None: which = get_settings().search_backend if which == "meili": # TODO(spec): Meilisearch backend lands in M2. raise NotImplementedError("meili backend is implemented in M2") _backend = PgSearchBackend() return _backend