scoreidcache-fix
All checks were successful
Deploy on push / deploy (push) Successful in 1m7s

This commit is contained in:
Untone 2024-06-02 15:32:02 +03:00
parent a3d1d1b067
commit 67e4cacb28
2 changed files with 11 additions and 4 deletions

View File

@ -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 []

View File

@ -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: