This commit is contained in:
parent
a3d1d1b067
commit
67e4cacb28
|
@ -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 []
|
||||
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue
Block a user