diff --git a/services/search.py b/services/search.py index 967c15fc..8c66e74f 100644 --- a/services/search.py +++ b/services/search.py @@ -24,13 +24,14 @@ class SearchService: if not cached: async with SearchService.lock: # Use aiohttp to send a request to ElasticSearch - # TODO: add limit offset usage async with aiohttp.ClientSession() as session: search_url = f"https://search.discours.io/search?q={text}" async with session.get(search_url) as response: if response.status == 200: payload = await response.json() await redis.execute("SET", text, json.dumps(payload)) - return payload + return payload[offset : offset + limit] + else: + print(f"[services.search] response: {response.status} {response.text}") else: - return json.loads(cached) + return json.loads(cached)[offset : offset + limit]