diff --git a/app/frontend/ui_graph_service.py b/app/frontend/ui_graph_service.py index 2e2e0bd..b521784 100644 --- a/app/frontend/ui_graph_service.py +++ b/app/frontend/ui_graph_service.py @@ -36,12 +36,6 @@ class GraphExplorerService: # --- LEVEL 2: Nachbarn der Nachbarn --- if depth > 1 and level_1_ids: - # Wir suchen Kanten, bei denen Source oder Target einer der L1 Nodes ist - # Wichtig: Wir filtern System-Edges schon in der Query oder Python, um Traffic zu sparen - - # Um die Performance zu wahren, limitieren wir die L2 Suche auf die IDs, die wir schon haben (als Source) - # Das ist ein "Ego-Network" Ansatz. - # Wir nehmen alle IDs aus Level 1 (außer Center, das haben wir schon) l1_subset = list(level_1_ids - {center_note_id}) @@ -84,8 +78,8 @@ class GraphExplorerService: if chunk_ids: out_f = models.Filter(must=[ models.FieldCondition(key="source_id", match=models.MatchAny(any=chunk_ids)), - # Filter System Edges - models.FieldCondition(key="kind", match=models.MatchExcept(except_=SYSTEM_EDGES)) + # FIX: MatchExcept mit **kwargs nutzen wegen 'except' Keyword + models.FieldCondition(key="kind", match=models.MatchExcept(**{"except": SYSTEM_EDGES})) ]) res_out, _ = self.client.scroll(self.edges_col, scroll_filter=out_f, limit=100, with_payload=True) results.extend(res_out) @@ -98,7 +92,8 @@ class GraphExplorerService: if shoulds: in_f = models.Filter( - must=[models.FieldCondition(key="kind", match=models.MatchExcept(except_=SYSTEM_EDGES))], + # FIX: MatchExcept mit **kwargs nutzen wegen 'except' Keyword + must=[models.FieldCondition(key="kind", match=models.MatchExcept(**{"except": SYSTEM_EDGES}))], should=shoulds ) res_in, _ = self.client.scroll(self.edges_col, scroll_filter=in_f, limit=100, with_payload=True) @@ -107,9 +102,7 @@ class GraphExplorerService: return results def _find_connected_edges_batch(self, note_ids): - """Batch-Suche für Level 2 (nur ausgehend und eingehend auf Note-Ebene, keine Title-Suche für Performance).""" - # Vereinfachte Suche: Wir suchen Kanten, die direkt mit den note_ids (oder deren Chunks) zu tun haben - # Um Performance zu sparen, machen wir hier einen simpleren Lookup, wenn möglich. + """Batch-Suche für Level 2 (nur ausgehend und eingehend auf Note-Ebene).""" return self._find_connected_edges(note_ids) def _process_edge(self, record, nodes_dict, unique_edges, current_depth): @@ -165,7 +158,7 @@ class GraphExplorerService: def _resolve_note_from_ref(self, ref_str): if not ref_str: return None - # ... (Logik identisch zu vorher, hier gekürzt für Übersicht) + # Fall A: Chunk ID / Section if "#" in ref_str: try: @@ -192,8 +185,8 @@ class GraphExplorerService: def _add_node_to_dict(self, node_dict, note_payload, level=1): nid = note_payload.get("note_id") - # Wenn Node schon da ist, aber wir finden ihn auf einem "höheren" Level (näher am Zentrum), updaten wir ihn nicht zwingend, - # außer wir wollen visuelle Eigenschaften ändern. + # Wenn Node schon da ist, aber wir finden ihn auf einem "höheren" Level (näher am Zentrum), + # updaten wir ihn nicht zwingend, außer wir wollen visuelle Eigenschaften ändern. if nid in node_dict: return ntype = note_payload.get("type", "default")