Skip to content

armgit / txtai

Public Imported from GitHub
0

💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows

Revert #1136 as it's confirmed to not be necessary

davidmezzetti5d15f7fa6680
diff --git a/src/python/txtai/graph/base.py b/src/python/txtai/graph/base.py
index 8262e74d..30449d9d 100644
--- a/src/python/txtai/graph/base.py
+++ b/src/python/txtai/graph/base.py
@@ -409,12 +409,6 @@ class Graph:
# Manually provided relationships and attributes to copy
relations, attributes = None, {}
- # Tracks whether this document consumes an indexid slot. Must match the same
- # key-presence criterion Transform.stream() uses to compute its offset, so node
- # ids stay in sync with the real vector index even when a text/object field is
- # present but set to None.
- hasfield = True
-
# Extract data from dictionary
if isinstance(document, dict):
# Extract relationships
@@ -429,20 +423,18 @@ class Graph:
}
# Require text or object field
- hasfield = self.text in document or self.object in document
document = document.get(self.text, document.get(self.object))
- if hasfield:
- if document is not None:
- if isinstance(document, list):
- # Join tokens as text
- document = " ".join(document)
+ if document is not None:
+ if isinstance(document, list):
+ # Join tokens as text
+ document = " ".join(document)
- # Create node
- nodes.append((index, {**{"id": uid, "data": document}, **attributes}))
+ # Create node
+ nodes.append((index, {**{"id": uid, "data": document}, **attributes}))
- # Add relationships
- self.addrelations(index, relations)
+ # Add relationships
+ self.addrelations(index, relations)
index += 1
diff --git a/test/python/testgraph.py b/test/python/testgraph.py
index 59c0f1fa..62d311b9 100644
--- a/test/python/testgraph.py
+++ b/test/python/testgraph.py
@@ -188,30 +188,6 @@ class TestGraph(unittest.TestCase):
self.assertTrue(graph.hasedge(0))
self.assertTrue(graph.hasedge(0, 1))
- def testInsertNoneTextIndexSync(self):
- """
- Test that a document with a present but None text/object field consumes an
- indexid slot without creating a node, keeping later node ids in sync with
- the real vector index offset (which increments on key presence, not on the
- resolved value being non-None - see Transform.stream()).
- """
-
- graph = GraphFactory.create({})
- graph.initialize()
-
- documents = [
- ("d0", {"text": "alpha content"}, None),
- ("d1", {"text": None}, None),
- ("d2", {"text": "gamma content"}, None),
- ]
- graph.insert(documents, index=0)
-
- # d1's slot (index 1) is consumed but has no node - d2 must land at index 2, not 1
- self.assertTrue(graph.hasnode(0))
- self.assertFalse(graph.hasnode(1))
- self.assertTrue(graph.hasnode(2))
- self.assertEqual(graph.node(2)["id"], "d2")
-
def testFilter(self):
"""
Test creating filtered subgraphs