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") scores[shout_id] = sr.get("score")
hits_ids.append(shout_id) hits_ids.append(shout_id)
result = local_session().execute(query_shouts()).unique() result = local_session().execute(query_shouts()).unique()
shouts = [] if result:
for shout in result: logger.debug(result)
shout.score = scores[f"{shout.id}"] shouts = []
shouts.append(shout) for shout in result:
shouts.sort(key=lambda x: x.score, reverse=True) shout.score = scores[f"{shout.id}"]
shouts.append(shout)
shouts.sort(key=lambda x: x.score, reverse=True)
return shouts return shouts
return [] return []

View File

@ -179,10 +179,9 @@ class SearchService:
body=search_body, body=search_body,
size=limit, size=limit,
from_=offset, from_=offset,
_source_includes=["_id", "_score"]) _source_excludes=["title", "body", "subtitle", "media", "lead"])
hits = search_response["hits"]["hits"] hits = search_response["hits"]["hits"]
results = [{"id": hit["_id"], "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: if results: