runabot/Christmas/SearchEngine/__init__.py

15 lines
473 B
Python
Raw Normal View History

2023-12-03 10:06:21 +00:00
from meilisearch_python_sdk import AsyncClient as Client
from Christmas.config import ChristmasConfig
class Search:
def __init__(self):
self.config = ChristmasConfig()
async def connect(self):
self.client = Client(self.config.SEARCH_ENGINE["HOST"], self.config.SEARCH_ENGINE["KEY"])
self.index = self.client.index(self.config.SEARCH_ENGINE["INDEX"])
return self.index
async def close(self):
await self.client.aclose()