This commit is contained in:
parent
5df82704b3
commit
7ad9b7919a
|
@ -97,18 +97,20 @@ class SearchService:
|
||||||
async def check_index(self):
|
async def check_index(self):
|
||||||
if self.client:
|
if self.client:
|
||||||
if not self.client.indices.exists(index=self.index_name):
|
if not self.client.indices.exists(index=self.index_name):
|
||||||
|
logger.debug(f' Новый индекс {self.index_name}')
|
||||||
self.create_index()
|
self.create_index()
|
||||||
logger.debug(f' Разметка индекации {self.index_name}')
|
|
||||||
self.client.indices.put_mapping(
|
self.client.indices.put_mapping(
|
||||||
index=self.index_name, body=expected_mapping
|
index=self.index_name, body=expected_mapping
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
logger.debug(f' Существующий индекс {self.index_name}')
|
||||||
# Check if the mapping is correct, and recreate the index if needed
|
# Check if the mapping is correct, and recreate the index if needed
|
||||||
mapping = self.client.indices.get_mapping(index=self.index_name)
|
mapping = self.client.indices.get_mapping(index=self.index_name)
|
||||||
if mapping != expected_mapping:
|
if mapping != expected_mapping:
|
||||||
await self.recreate_index()
|
await self.recreate_index()
|
||||||
|
|
||||||
async def recreate_index(self):
|
async def recreate_index(self):
|
||||||
|
logger.debug(' Пересоздание индексов...')
|
||||||
async with asyncio.Lock():
|
async with asyncio.Lock():
|
||||||
self.delete_index()
|
self.delete_index()
|
||||||
await self.check_index()
|
await self.check_index()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user