diff --git a/resolvers/reader.py b/resolvers/reader.py index b350595b..ff128b3e 100644 --- a/resolvers/reader.py +++ b/resolvers/reader.py @@ -297,8 +297,15 @@ async def load_shouts_feed(_, info, options): async def load_shouts_search(_, _info, text, limit=50, offset=0): if isinstance(text, str) and len(text) > 2: results = await search_text(text, limit, offset) - logger.debug(results) - return results + shouts_ids = [] + for sr in results: + shout_id = sr.get("id") + if shout_id: + shouts_ids.append(int(shout_id)) + shouts = [] + with local_session() as session: + shouts = session.query(Shout).filter(Shout.id.in_(shouts_ids)).all() + return shouts return [] diff --git a/services/search.py b/services/search.py index 887d11a5..6e0511cc 100644 --- a/services/search.py +++ b/services/search.py @@ -177,8 +177,8 @@ class SearchService: if self.client: search_response = self.client.search(index=self.index_name, body=search_body, size=limit, from_=offset) hits = search_response["hits"]["hits"] - - results = [{**hit["_source"], "score": hit["_score"]} for hit in hits] + results = [{"id": hit["_id"], "score": hit["_score"]} for hit in hits] + # results = [{**hit["_source"], "score": hit["_score"]} for hit in hits] # если результаты не пустые if results: