]> git.openstreetmap.org Git - osqa.git/blobdiff - forum_modules/pgfulltext/handlers.py
Added the option to limit the tags creation. It will defaults to false, and there...
[osqa.git] / forum_modules / pgfulltext / handlers.py
index ff29f14823f7b8ac2db06aa7dba4bdda84c135c9..e46c5719ba8a3cf4fddd92971e660ece1ee1d2fe 100644 (file)
@@ -4,7 +4,7 @@ from forum.modules.decorators import decorate
 
 @decorate(QuestionManager.search, needs_origin=False)
 def question_search(self, keywords):
-    tsquery = " | ".join(keywords.split(' '))
+    tsquery = " | ".join([k for k in keywords.split(' ') if k])
     
     return self.extra(
                     tables = ['forum_rootnode_doc'],
@@ -15,7 +15,7 @@ def question_search(self, keywords):
                     },
                     where=["""
                            "forum_rootnode_doc"."node_id" = "forum_node"."id" AND ("forum_rootnode_doc"."document" @@ to_tsquery('english', %s) OR
-                           "forum_node"."title" ILIKE '""" + keywords + """%%')
+                           "forum_node"."title" ILIKE '""" + keywords.replace("'",r"\'") + """%%')
                            """],
                     params=[tsquery],
                     select_params=[tsquery],