From f595834c6047048c08943070ca795abdbcff9f96 Mon Sep 17 00:00:00 2001 From: yangdx Date: Thu, 24 Apr 2025 17:59:34 +0800 Subject: [PATCH] Fix index creating bugs for PostgreSQL AGE graph storage --- lightrag/kg/postgres_impl.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lightrag/kg/postgres_impl.py b/lightrag/kg/postgres_impl.py index 213eced4..6c247fc3 100644 --- a/lightrag/kg/postgres_impl.py +++ b/lightrag/kg/postgres_impl.py @@ -1086,9 +1086,11 @@ class PGGraphStorage(BaseGraphStorage): # 分别执行每个语句,忽略错误 queries = [ f"SELECT create_graph('{self.graph_name}')", - f'CREATE INDEX CONCURRENTLY vertex_p_idx ON {self.graph_name}."_ag_label_vertex" (id)', + f"SELECT create_vlabel('{self.graph_name}', 'base');", + f"SELECT create_elabel('{self.graph_name}', 'DIRECTED');", + # f'CREATE INDEX CONCURRENTLY vertex_p_idx ON {self.graph_name}."_ag_label_vertex" (id)', f'CREATE INDEX CONCURRENTLY vertex_idx_node_id ON {self.graph_name}."_ag_label_vertex" (ag_catalog.agtype_access_operator(properties, \'"entity_id"\'::agtype))', - f'CREATE INDEX CONCURRENTLY edge_p_idx ON {self.graph_name}."_ag_label_edge" (id)', + # f'CREATE INDEX CONCURRENTLY edge_p_idx ON {self.graph_name}."_ag_label_edge" (id)', f'CREATE INDEX CONCURRENTLY edge_sid_idx ON {self.graph_name}."_ag_label_edge" (start_id)', f'CREATE INDEX CONCURRENTLY edge_eid_idx ON {self.graph_name}."_ag_label_edge" (end_id)', f'CREATE INDEX CONCURRENTLY edge_seid_idx ON {self.graph_name}."_ag_label_edge" (start_id,end_id)',