mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-14 07:42:11 +02:00
fix: index literal objects in entity table for object-based graph queries (#1042)
Literal objects (e.g. rdfs:label values) were not being inserted into the quads_by_entity table with role='O', so queries like `tg-query-graph -o MIL-HDBK-516D` returned no results even though the triple existed. Removed the otype guard that skipped entity row insertion for literals in both insert() and async_insert(). Also updated delete_collection() and async_delete_collection() to include literal objects in entity partition cleanup. Existing data requires re-ingestion for old literal objects to become queryable by object value.
This commit is contained in:
parent
35fc8444ec
commit
f9f5a2318f
3 changed files with 141 additions and 27 deletions
|
|
@ -776,11 +776,10 @@ class EntityCentricKnowledgeGraph:
|
|||
collection, p, 'P', p, otype, s, o, g, dtype, lang
|
||||
))
|
||||
|
||||
# Write row for object entity (role='O') - only for URIs, not literals
|
||||
if otype == 'u' or otype == 't':
|
||||
batch.add(self.insert_entity_stmt, (
|
||||
collection, o, 'O', p, otype, s, o, g, dtype, lang
|
||||
))
|
||||
# Write row for object entity (role='O')
|
||||
batch.add(self.insert_entity_stmt, (
|
||||
collection, o, 'O', p, otype, s, o, g, dtype, lang
|
||||
))
|
||||
|
||||
# Write row for graph entity (role='G') - only for non-default graphs
|
||||
if g != DEFAULT_GRAPH:
|
||||
|
|
@ -997,15 +996,10 @@ class EntityCentricKnowledgeGraph:
|
|||
lang = row.lang if hasattr(row, 'lang') else ''
|
||||
quads.append((d, s, p, o, otype, dtype, lang))
|
||||
|
||||
# Subject and predicate are always entities
|
||||
entities.add(s)
|
||||
entities.add(p)
|
||||
entities.add(o)
|
||||
|
||||
# Object is an entity only for URIs
|
||||
if otype == 'u' or otype == 't':
|
||||
entities.add(o)
|
||||
|
||||
# Graph is an entity for non-default graphs
|
||||
if d != DEFAULT_GRAPH:
|
||||
entities.add(d)
|
||||
|
||||
|
|
@ -1067,8 +1061,7 @@ class EntityCentricKnowledgeGraph:
|
|||
batch = BatchStatement()
|
||||
batch.add(self.insert_entity_stmt, (collection, s, 'S', p, otype, s, o, g, dtype, lang))
|
||||
batch.add(self.insert_entity_stmt, (collection, p, 'P', p, otype, s, o, g, dtype, lang))
|
||||
if otype == 'u' or otype == 't':
|
||||
batch.add(self.insert_entity_stmt, (collection, o, 'O', p, otype, s, o, g, dtype, lang))
|
||||
batch.add(self.insert_entity_stmt, (collection, o, 'O', p, otype, s, o, g, dtype, lang))
|
||||
if g != DEFAULT_GRAPH:
|
||||
batch.add(self.insert_entity_stmt, (collection, g, 'G', p, otype, s, o, g, dtype, lang))
|
||||
batch.add(self.insert_collection_stmt, (collection, g, s, p, o, otype, dtype, lang))
|
||||
|
|
@ -1233,8 +1226,7 @@ class EntityCentricKnowledgeGraph:
|
|||
quads.append((d, s, p, o, otype, dtype, lang))
|
||||
entities.add(s)
|
||||
entities.add(p)
|
||||
if otype == 'u' or otype == 't':
|
||||
entities.add(o)
|
||||
entities.add(o)
|
||||
if d != DEFAULT_GRAPH:
|
||||
entities.add(d)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue