From 72384f87c4f26c2e30d3a0fa635bba8a7de6d4b7 Mon Sep 17 00:00:00 2001 From: yangdx Date: Wed, 25 Jun 2025 12:53:07 +0800 Subject: [PATCH] Remove deprecated code from Postgres_impl.py - Stop filtering out 'base' node labels - Match any edge type in query to improve performance --- lightrag/kg/postgres_impl.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lightrag/kg/postgres_impl.py b/lightrag/kg/postgres_impl.py index dd93d624..0ddc7948 100644 --- a/lightrag/kg/postgres_impl.py +++ b/lightrag/kg/postgres_impl.py @@ -1701,10 +1701,11 @@ class PGGraphStorage(BaseGraphStorage): ) # Remove the 'base' label if present in a 'labels' property - if "labels" in node_dict: - node_dict["labels"] = [ - label for label in node_dict["labels"] if label != "base" - ] + # if "labels" in node_dict: + # node_dict["labels"] = [ + # label for label in node_dict["labels"] if label != "base" + # ] + nodes_dict[result["node_id"]] = node_dict return nodes_dict @@ -1833,14 +1834,14 @@ class PGGraphStorage(BaseGraphStorage): forward_query = f"""SELECT * FROM cypher('{self.graph_name}', $$ WITH [{src_array}] AS sources, [{tgt_array}] AS targets UNWIND range(0, size(sources)-1) AS i - MATCH (a:base {{entity_id: sources[i]}})-[r:DIRECTED]->(b:base {{entity_id: targets[i]}}) + MATCH (a:base {{entity_id: sources[i]}})-[r]->(b:base {{entity_id: targets[i]}}) RETURN sources[i] AS source, targets[i] AS target, properties(r) AS edge_properties $$) AS (source text, target text, edge_properties agtype)""" backward_query = f"""SELECT * FROM cypher('{self.graph_name}', $$ WITH [{src_array}] AS sources, [{tgt_array}] AS targets UNWIND range(0, size(sources)-1) AS i - MATCH (a:base {{entity_id: sources[i]}})<-[r:DIRECTED]-(b:base {{entity_id: targets[i]}}) + MATCH (a:base {{entity_id: sources[i]}})<-[r]-(b:base {{entity_id: targets[i]}}) RETURN sources[i] AS source, targets[i] AS target, properties(r) AS edge_properties $$) AS (source text, target text, edge_properties agtype)"""