💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows
Python agentsaiai-agentsembeddingsinformation-retrievallanguage-modellarge-language-modelsllmnlppythonragretrieval-augmented-generationsearchsearch-enginesemantic-searchsentence-embeddingstransformerstxtaivector-databasevector-search
Fix empty reindex when columns.store doesn't include the text column
Tanishqb68b40461115
diff --git a/src/python/txtai/database/rdbms.py b/src/python/txtai/database/rdbms.pyindex 3729ad03..a5b220e2 100644--- a/src/python/txtai/database/rdbms.py+++ b/src/python/txtai/database/rdbms.py@@ -97,6 +97,10 @@ class RDBMS(Database):# Read JSON data, if provideddata = json.loads(data) if data and isinstance(data, str) else data+ # Add section text when the JSON data doesn't store the text column+ if isinstance(data, dict) and self.text not in data:+ data[self.text] = text+# Stream data if available, otherwise use section textyield (uid, data if data else text, tags)diff --git a/test/python/testdatabase/testrdbms.py b/test/python/testdatabase/testrdbms.pyindex e45403ff..96d633b0 100644--- a/test/python/testdatabase/testrdbms.py+++ b/test/python/testdatabase/testrdbms.py@@ -656,6 +656,26 @@ class Common:self.assertEqual(result["text"], self.data[4])+ def testReindexStore(self):+ """+ Test reindex when the JSON data doesn't store the text column+ """++ # Index documents and only store the title field in the JSON data+ embeddings = Embeddings({"keyword": True, "content": self.backend, "columns": {"store": ["title"]}})+ embeddings.index([{"id": uid, "text": text, "title": f"Title {uid}"} for uid, text in enumerate(self.data)])++ # Reindex+ embeddings.reindex({"keyword": True, "columns": {"store": ["title"]}})++ # Test all documents are indexed+ self.assertEqual(embeddings.count(), len(self.data))++ # Search for best match+ result = embeddings.search("select id, text, title from txtai where similar('lottery ticket')", 1)[0]+ self.assertEqual(result["text"], self.data[4])+ self.assertEqual(result["title"], "Title 4")+def testSave(self):"""Test save