From 3e5d0a146fcda01a984818d381f31a19287aead8 Mon Sep 17 00:00:00 2001
From: Sabin Mendiguren <sabin.mendiguren@gmail.com>
Date: Mon, 11 Mar 2024 19:49:44 +0100
Subject: [PATCH] Fixes for add and delete Methods in LanceDBVectorStore
 (#11825)

fix: Fixes for add and delete Methods in LanceDBVectorStore
---
 .../llama_index/vector_stores/lancedb/base.py                | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/llama-index-integrations/vector_stores/llama-index-vector-stores-lancedb/llama_index/vector_stores/lancedb/base.py b/llama-index-integrations/vector_stores/llama-index-vector-stores-lancedb/llama_index/vector_stores/lancedb/base.py
index 6a4e7b8468..9da3db75ac 100644
--- a/llama-index-integrations/vector_stores/llama-index-vector-stores-lancedb/llama_index/vector_stores/lancedb/base.py
+++ b/llama-index-integrations/vector_stores/llama-index-vector-stores-lancedb/llama_index/vector_stores/lancedb/base.py
@@ -154,6 +154,9 @@ class LanceDBVectorStore(BasePydanticVectorStore):
         nodes: List[BaseNode],
         **add_kwargs: Any,
     ) -> List[str]:
+        if not nodes:
+            _logger.debug("No nodes to add. Skipping the database operation.")
+            return []
         data = []
         ids = []
         for node in nodes:
@@ -186,7 +189,7 @@ class LanceDBVectorStore(BasePydanticVectorStore):
 
         """
         table = self._connection.open_table(self.table_name)
-        table.delete('document_id = "' + ref_doc_id + '"')
+        table.delete('doc_id = "' + ref_doc_id + '"')
 
     def query(
         self,
-- 
GitLab