Merge pull request #1073 from danielaskdd/fix-neo4j-single-node

Fix get single node subgrap problem
This commit is contained in:
Daniel.y 2025-03-13 02:16:17 +08:00 committed by GitHub
commit 3f208fc1af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

6
.gitignore vendored
View File

@ -64,3 +64,9 @@ gui/
# unit-test files
test_*
# Cline files
memory-bank/
# Cline files
memory-bank/

View File

@ -661,7 +661,7 @@ class Neo4JStorage(BaseGraphStorage):
WITH collect({node: n}) AS filtered_nodes
UNWIND filtered_nodes AS node_info
WITH collect(node_info.node) AS kept_nodes, filtered_nodes
MATCH (a)-[r]-(b)
OPTIONAL MATCH (a)-[r]-(b)
WHERE a IN kept_nodes AND b IN kept_nodes
RETURN filtered_nodes AS node_info,
collect(DISTINCT r) AS relationships
@ -704,7 +704,7 @@ class Neo4JStorage(BaseGraphStorage):
WITH collect({node: node}) AS filtered_nodes
UNWIND filtered_nodes AS node_info
WITH collect(node_info.node) AS kept_nodes, filtered_nodes
MATCH (a)-[r]-(b)
OPTIONAL MATCH (a)-[r]-(b)
WHERE a IN kept_nodes AND b IN kept_nodes
RETURN filtered_nodes AS node_info,
collect(DISTINCT r) AS relationships