Skip to content

Commit

Permalink
Return hits & search terms
Browse files Browse the repository at this point in the history
  • Loading branch information
frostyfan109 committed Jun 8, 2022
1 parent 93f0a78 commit 765a1e9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions PLATER/services/util/graph_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@ def search(self, query, indexes, fields=None, options={
# Replace more than 1 consecutive space with just 1 space.
cleaned_query = re.sub(" +", " ", cleaned_query)
cleaned_query = cleaned_query.strip()
search_terms = cleaned_query.split(" ")
if prefix_search: cleaned_query += "*"
elif levenshtein_distance:
if levenshtein_distance:
# Enforced maximum LD by Redisearch.
if levenshtein_distance > 3: levenshtein_distance = 3
levenshtein_str = "%" * levenshtein_distance # e.g. LD = 3; "short phrase" => "%%%short%%% %%%phrase%%%"
Expand Down Expand Up @@ -132,7 +133,10 @@ def search(self, query, indexes, fields=None, options={
hit["node"] = dict(dict(hit["node"])["properties"])
hit["score"] = float(hit["score"])
hits.sort(key=lambda hit: hit["score"], reverse=True)
return hits
return {
"hits": hits,
"search_terms": search_terms
}

def get_schema(self, force_update=False):
"""
Expand Down

0 comments on commit 765a1e9

Please sign in to comment.