diff --git a/app/plugins/builtins/unified_search/jobs.py b/app/plugins/builtins/unified_search/jobs.py index fd8305d..6bb710f 100644 --- a/app/plugins/builtins/unified_search/jobs.py +++ b/app/plugins/builtins/unified_search/jobs.py @@ -13,11 +13,15 @@ logger = logging.getLogger(__name__) BATCH_SIZE = 100 # Entity type -> table name mapping (shared by multiple jobs) +# F31 (Astra P2): derived from the SINGLE shared source (search_engine) +# instead of a diverging fixed copy — a new provider with a tsv/embedding +# table is now automatically covered by reindex and similarity search. +from app.plugins.builtins.unified_search.search_engine import ( # noqa: E402 + SEARCHABLE_ENTITIES, +) + _TABLE_MAP: dict[str, str] = { - "contact": "contacts", - "mail": "mails", - "file": "files", - "event": "calendar_entries", + entity_type: info[0] for entity_type, info in SEARCHABLE_ENTITIES.items() } @@ -243,8 +247,19 @@ async def reindex(ctx: dict[str, Any], entity_type: str) -> None: async def reindex_all(ctx: dict[str, Any]) -> None: - """Reindex all entity types in sequence, including file chunks.""" - entity_types = ["contact", "mail", "file", "event"] + """Reindex all searchable entity types in sequence, including file chunks. + + F31 (Astra P2): iterates DYNAMICALLY over the registered search + providers ∩ SEARCHABLE_ENTITIES instead of a fixed 4-type list — a new + provider with a tsv/embedding table is now automatically reindexed. + """ + from app.plugins.builtins.unified_search.provider_registry import get_search_registry + + try: + registered = set(get_search_registry().get_entity_types()) + except Exception: + registered = set() + entity_types = [et for et in _TABLE_MAP if not registered or et in registered] for etype in entity_types: try: await reindex(ctx, etype)