From cd67d7cd7958188b019097e585d307492a8d5c92 Mon Sep 17 00:00:00 2001 From: yangdx Date: Wed, 2 Apr 2025 12:16:13 +0800 Subject: [PATCH] Removed redundant entity_id extraction in upsert logic for Neo4JStorage --- lightrag/kg/neo4j_impl.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lightrag/kg/neo4j_impl.py b/lightrag/kg/neo4j_impl.py index f9e56032..b6e60b57 100644 --- a/lightrag/kg/neo4j_impl.py +++ b/lightrag/kg/neo4j_impl.py @@ -517,7 +517,6 @@ class Neo4JStorage(BaseGraphStorage): """ properties = node_data entity_type = properties["entity_type"] - entity_id = properties["entity_id"] if "entity_id" not in properties: raise ValueError("Neo4j: node properties must contain an 'entity_id' field") @@ -527,15 +526,15 @@ class Neo4JStorage(BaseGraphStorage): async def execute_upsert(tx: AsyncManagedTransaction): query = ( """ - MERGE (n:base {entity_id: $properties.entity_id}) + MERGE (n:base {entity_id: $entity_id}) SET n += $properties SET n:`%s` """ % entity_type ) - result = await tx.run(query, properties=properties) + result = await tx.run(query, entity_id=node_id, properties=properties) logger.debug( - f"Upserted node with entity_id '{entity_id}' and properties: {properties}" + f"Upserted node with entity_id '{node_id}' and properties: {properties}" ) await result.consume() # Ensure result is fully consumed