From 45815f1eaeb44b8f671ec39f858b003e4c7d0aa5 Mon Sep 17 00:00:00 2001 From: DavIvek Date: Mon, 14 Jul 2025 15:39:39 +0200 Subject: [PATCH] remove redundant UNWIND --- lightrag/kg/memgraph_impl.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lightrag/kg/memgraph_impl.py b/lightrag/kg/memgraph_impl.py index 4b640d2d..3683a8e3 100644 --- a/lightrag/kg/memgraph_impl.py +++ b/lightrag/kg/memgraph_impl.py @@ -825,14 +825,14 @@ class MemgraphStorage(BaseGraphStorage): END AS limited_nodes, size(all_nodes_unlimited) > $max_nodes AS is_truncated - UNWIND limited_nodes AS n1 - UNWIND limited_nodes AS n2 - MATCH (n1)-[r]-(n2) - WITH DISTINCT r, limited_nodes, is_truncated + UNWIND limited_nodes AS n + MATCH (n)-[r]-(m) + WHERE m IN limited_nodes + WITH collect(DISTINCT n) AS limited_nodes, collect(DISTINCT r) AS relationships, is_truncated RETURN [node IN limited_nodes | {{node: node}}] AS node_info, - collect(DISTINCT r) AS relationships, + relationships, is_truncated """