Make the search action not return scores of zero if there is no character matching

This commit is contained in:
Joseph Schorr 2015-04-20 13:00:38 -04:00
parent 16e05e83b1
commit ae55b8dd0e

View file

@ -291,6 +291,7 @@ class ConductSearch(ApiResource):
# Modify the results' scores via how close the query term is to each result's name.
for result in results:
name = result.get('short_name', result['name'])
result['score'] = result['score'] * liquidmetal.score(name, query)
lm_score = liquidmetal.score(name, query) or 1
result['score'] = result['score'] * lm_score
return {'results': sorted(results, key=itemgetter('score'), reverse=True)}