Skip to content

Commit 9b7bbc7

Browse files
committed
formatting and logic change to resolve_relations, remove fuzzy search
1 parent 138c283 commit 9b7bbc7

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/basic_memory/db.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,10 @@ async def run_migrations(
350350
# For SQLite: Create FTS5 virtual table
351351
# For Postgres: No-op (tsvector column added by migrations)
352352
# The project_id is not used for init_search_index, so we pass a dummy value
353-
if database_type == DatabaseType.POSTGRES or app_config.database_backend == DatabaseBackend.POSTGRES:
353+
if (
354+
database_type == DatabaseType.POSTGRES
355+
or app_config.database_backend == DatabaseBackend.POSTGRES
356+
):
354357
await PostgresSearchRepository(session_maker, 1).init_search_index()
355358
else:
356359
await SQLiteSearchRepository(session_maker, 1).init_search_index()

src/basic_memory/services/entity_service.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,11 @@ async def update_entity_relations(
448448
import asyncio
449449

450450
# Create tasks for all relation lookups
451+
# Use strict=True to disable fuzzy search - only exact matches should create resolved relations
452+
# This ensures forward references (links to non-existent entities) remain unresolved (to_id=NULL)
451453
lookup_tasks = [
452-
self.link_resolver.resolve_link(rel.target) for rel in markdown.relations
454+
self.link_resolver.resolve_link(rel.target, strict=True)
455+
for rel in markdown.relations
453456
]
454457

455458
# Execute all lookups in parallel

0 commit comments

Comments
 (0)