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