]> git.ipfire.org Git - people/shoehn/ipfire.org.git/blobdiff - webapp/backend/planet.py
planet: Add fulltext search.
[people/shoehn/ipfire.org.git] / webapp / backend / planet.py
index 9dae689da82dfcd51a9d4bac0e79aa26ddfd81fb..62b8bf0ca4fd05b613e141a9a1d7347044c8393f 100644 (file)
@@ -160,3 +160,8 @@ class Planet(object):
                        "VALUES(%s, %s, %s, %s, UTC_TIMESTAMP())", entry.author.uid, entry.title,
                        slug, entry.markdown)
 
+       def search(self, what):
+               entries = self.db.query("SELECT *, MATCH(markdown, title) AGAINST(%s) AS score \
+                       FROM planet WHERE MATCH(markdown, title) AGAINST(%s) ORDER BY score DESC", what, what)
+
+               return [PlanetEntry(e) for e in entries]