runabot/Christmas/SearchEngine/__init__.py
2023-12-03 19:06:21 +09:00

15 lines
473 B
Python

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()