| 1234567891011121314151617 |
- from __future__ import annotations
- from app.core.config import GlobalConfigSettings
- from app.infra.external import AsyncElasticSearchClient
- class ElasticSearchManager:
- def __init__(self, config: GlobalConfigSettings):
- self.config = config
- async def search(self, keywords: str, size: int = 10) -> dict:
- async with AsyncElasticSearchClient(self.config) as client:
- results = await client.search(search_keys=keywords, size=size)
- return {
- "total": len(results),
- "results": results,
- }
|