Somewhat re-thought TrigramSearchManager (using greatest instead of max).

This commit is contained in:
Schuyler Erle 2012-02-28 19:00:24 +05:30
parent 0cf8fae70b
commit ddfbe2646e

View File

@ -54,7 +54,7 @@ class TrigramSearchManager(models.Manager):
def find_approximate(self, text, match=0.5):
self.set_threshold(match)
similarity_measure = "max(%s)" % ",".join(["similarity(%s, %%s)" % col for col in self.trigram_columns])
similarity_measure = "greatest(%s)" % ",".join(["similarity(%s, %%s)" % col for col in self.trigram_columns])
similarity_filter = " OR ".join(["%s %%%% %%s" % col for col in self.trigram_columns])
text_values = [text] * len(self.trigram_columns)