From df15e63dde651a3c803210281a5f21700dea13cf Mon Sep 17 00:00:00 2001 From: Untone Date: Mon, 8 Apr 2024 10:23:54 +0300 Subject: [PATCH] reindex-fix --- services/search.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/services/search.py b/services/search.py index 2c1f88b2..9e5333ac 100644 --- a/services/search.py +++ b/services/search.py @@ -131,9 +131,11 @@ class SearchService: if self.client: id_ = str(shout.id) logger.debug(f' Индексируем пост {id_}') - asyncio.create_task( - self.client.index(index=self.index_name, id=id_, body=shout.dict()) - ) + asyncio.create_task(self.perform_index(shout)) + + async def perform_index(self, shout): + if self.client: + await self.client.index(index=self.index_name, id=str(shout.id), body=shout.dict()) async def search(self, text, limit, offset): logger.debug(f' Ищем: {text}')