Order overlaps results by similarity if text is provideed.
This commit is contained in:
parent
abd06fc0e2
commit
960eb21283
|
@ -24,7 +24,9 @@ class FeatureSearchManager(models.GeoManager):
|
|||
if text:
|
||||
text = text.replace("'", "''") # escape the '
|
||||
# use the pg_trgm index
|
||||
qset = qset.extra(where=["preferred_name %%%% '%s'" % text])
|
||||
qset = qset.extra(select={"similarity":"similarity(preferred_name, '%s')" % text},
|
||||
where=["preferred_name %%%% '%s'" % text],
|
||||
order_by=["-similarity"])
|
||||
return qset
|
||||
|
||||
class Feature(models.Model):
|
||||
|
|
Loading…
Reference in New Issue
Block a user