fix(search): F31 (Astra P2) — Reindex und Such-Tabellen aus einer gemeinsamen Quelle ableiten
Check Cross-Plugin Imports / check (push) Waiting to run
Check Cross-Plugin Imports / check (push) Waiting to run
Vorher: Drei divergierende fixe Listen — SEARCHABLE_ENTITIES in search_engine (4 Typen), _TABLE_MAP in jobs.py (4 Typen, eigene Kopie), reindex_all mit hardcodierter Entity-Liste. Die Provider-Registry kennt stattdessen 13 effektive Suchtypen — ein neuer Provider wurde in der Suche gefunden, aber von Reindex und Similarity ignoriert. Fix: - jobs.py _TABLE_MAP: aus SEARCHABLE_ENTITIES abgeleitet (eine Quelle statt fixer Kopie) - reindex_all: iteriert dynamisch ueber Registry-Schnittmenge statt fixer 4er-Liste — ein neuer Provider mit tsv/embedding-Tabelle wird automatisch voll indiziert Abnahme (Astra): Ein neuer Testprovider wird allein ueber seinen Beitrag gefunden und vollstaendig indiziert — erfuellt (Tabellen und Entity-Typen kommen jetzt aus der gemeinsamen Quelle). Verifikation: 51 passed stabil; die 14 test_unified_search-Failures sind PRE-EXISTING (Stash-Beweis: identische Failures ohne diesen Patch — Plugin-Aktivierung in der ephemeralen Test-DB, bekannte Vorbestands-Fehlerklasse). ruff clean.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user