From: Michael Tremer Date: Sun, 17 Feb 2013 13:58:41 +0000 (+0100) Subject: Alter search so that no FULLTEXT index is required. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ce7abd335707200fc83e0a767efc02805f74b293;p=people%2Fjschlag%2Fpbs.git Alter search so that no FULLTEXT index is required. Our version of MySQL does not support FULLTEXT indexes with InnoDB. --- diff --git a/backend/packages.py b/backend/packages.py index 2682c6b..6b92eb9 100644 --- a/backend/packages.py +++ b/backend/packages.py @@ -64,13 +64,22 @@ class Packages(base.Object): This function does not work for UUIDs or filenames. """ - query = "SELECT id FROM packages WHERE type = 'source' AND \ - (name LIKE %s OR MATCH(name, summary, description) AGAINST(%s)) \ + query = "SELECT * FROM packages \ + WHERE type = %s AND ( \ + name LIKE %s OR \ + summary LIKE %s OR \ + description LIKE %s \ + ) \ GROUP BY name" + pattern = "%%%s%%" % pattern + args = ("source", pattern, pattern, pattern) + + res = self.db.query(query, *args) + pkgs = [] - for pkg in self.db.query(query, pattern, pattern): - pkg = Package(self.pakfire, pkg.id) + for row in res: + pkg = Package(self.pakfire, row.id, row) pkgs.append(pkg) if limit and len(pkgs) >= limit: