From c1ea47026d6a03c45d76186b8f9a6d6fb8456a97 Mon Sep 17 00:00:00 2001 From: yangdx Date: Wed, 16 Apr 2025 13:27:03 +0800 Subject: [PATCH] Fix index error on empty database --- lightrag/kg/postgres_impl.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lightrag/kg/postgres_impl.py b/lightrag/kg/postgres_impl.py index 9528aee8..7c52b178 100644 --- a/lightrag/kg/postgres_impl.py +++ b/lightrag/kg/postgres_impl.py @@ -1027,6 +1027,16 @@ class PGGraphStorage(BaseGraphStorage): if self.db is None: self.db = await ClientManager.get_client() + node1_id = "dummy_entity" + node1_data = { + "entity_id": node1_id, + "description": "dummy description", + "keywords": "dummy,keywords", + "entity_type": "dummy_type", + } + await self.upsert_node(node1_id, node1_data) + await self.delete_node(node1_id) + query = """CREATE INDEX entity_id_gin_idxSELECT ON %s."base" USING gin (properties);""" % (self.graph_name) await self.db.execute(