search-with-images22
All checks were successful
Deploy on push / deploy (push) Successful in 1m9s

This commit is contained in:
Untone 2024-06-02 18:34:15 +03:00
parent ebf1309b48
commit c1fe419ff9
2 changed files with 8 additions and 7 deletions

View File

@ -307,11 +307,13 @@ async def load_shouts_search(_, _info, text, limit=50, offset=0):
scores[shout_id] = sr.get("score")
hits_ids.append(shout_id)
result = local_session().execute(query_shouts()).unique()
shouts = []
for shout in result:
shout.score = scores[f"{shout.id}"]
shouts.append(shout)
shouts.sort(key=lambda x: x.score, reverse=True)
if result:
logger.debug(result)
shouts = []
for shout in result:
shout.score = scores[f"{shout.id}"]
shouts.append(shout)
shouts.sort(key=lambda x: x.score, reverse=True)
return shouts
return []

View File

@ -179,10 +179,9 @@ class SearchService:
body=search_body,
size=limit,
from_=offset,
_source_includes=["_id", "_score"])
_source_excludes=["title", "body", "subtitle", "media", "lead"])
hits = search_response["hits"]["hits"]
results = [{"id": hit["_id"], "score": hit["_score"]} for hit in hits]
# results = [{**hit["_source"], "score": hit["_score"]} for hit in hits]
# если результаты не пустые
if results: