Skip to content

Commit 2744c4b

Browse files
committed
add info logging to index_entity_data background task
Signed-off-by: phernandez <[email protected]>
1 parent fd732aa commit 2744c4b

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

src/basic_memory/services/search_service.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,29 @@ async def index_entity_data(
184184
entity: Entity,
185185
content: str | None = None,
186186
) -> None:
187-
# delete all search index data associated with entity
188-
await self.repository.delete_by_entity_id(entity_id=entity.id)
189-
190-
# reindex
191-
await self.index_entity_markdown(
192-
entity, content
193-
) if entity.is_markdown else await self.index_entity_file(entity)
187+
logger.info(
188+
f"[BackgroundTask] Starting search index for entity_id={entity.id} "
189+
f"permalink={entity.permalink} project_id={entity.project_id}"
190+
)
191+
try:
192+
# delete all search index data associated with entity
193+
await self.repository.delete_by_entity_id(entity_id=entity.id)
194+
195+
# reindex
196+
await self.index_entity_markdown(
197+
entity, content
198+
) if entity.is_markdown else await self.index_entity_file(entity)
199+
200+
logger.info(
201+
f"[BackgroundTask] Completed search index for entity_id={entity.id} "
202+
f"permalink={entity.permalink}"
203+
)
204+
except Exception as e:
205+
logger.error(
206+
f"[BackgroundTask] Failed search index for entity_id={entity.id} "
207+
f"permalink={entity.permalink} error={e}"
208+
)
209+
raise
194210

195211
async def index_entity_file(
196212
self,

0 commit comments

Comments
 (0)