Skip to content

Commit

Permalink
fix(HelpdeskSearch): Remove duplicates from results
Browse files Browse the repository at this point in the history
- Return results even if no nouns
  • Loading branch information
balamurali27 committed Oct 14, 2024
1 parent 1227646 commit 4c74e83
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions helpdesk/api/article.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def search_with_enough_results(prev_res: list, query: str) -> tuple[list, bool]:
out = hd_search(query, only_articles=True)
if not out:
return prev_res, len(prev_res) == NUM_RESULTS
items = (prev_res + out[0].get("items", []))[:NUM_RESULTS]
items = prev_res + out[0].get("items", [])
items = list({v["id"]: v for v in items}.values())[:NUM_RESULTS] # unique results
return items, len(items) == NUM_RESULTS


Expand All @@ -50,4 +51,5 @@ def search(query: str) -> list:
if enough:
return ret
or_query = "|".join(nouns)
return search_with_enough_results(ret, or_query)[0]
ret, enough = search_with_enough_results(ret, or_query)
return ret

0 comments on commit 4c74e83

Please sign in to comment.