]> git.openstreetmap.org Git - osqa.git/commitdiff
Ultimate fix for the search query problem.
authorhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Thu, 24 Jun 2010 23:24:42 +0000 (23:24 +0000)
committerhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Thu, 24 Jun 2010 23:24:42 +0000 (23:24 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@445 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum_modules/pgfulltext/handlers.py

index 69527580c18f59e5232bab1553001b3124cdf6ee..5f1827048b15b892afeded7e27eb6cf57b3310bb 100644 (file)
@@ -3,12 +3,11 @@ from django.db.models import Q
 from forum.models.question import Question, QuestionManager
 from forum.modules import decorate
 
 from forum.models.question import Question, QuestionManager
 from forum.modules import decorate
 
-repl_re = re.compile(r"^'|[^\'\-_\s\w]|'$", re.UNICODE)
-sing_quote_re = re.compile(r"\'+")
+word_re = re.compile(r'\w+', re.UNICODE)
 
 @decorate(QuestionManager.search, needs_origin=False)
 def question_search(self, keywords):
 
 @decorate(QuestionManager.search, needs_origin=False)
 def question_search(self, keywords):
-    tsquery = " | ".join([k for k in repl_re.sub('', sing_quote_re.sub("'", keywords.strip())).split(' ') if k])
+    tsquery = " | ".join(word_re.findall(keywords))
     ilike = keywords + u"%%"
 
     return self.extra(
     ilike = keywords + u"%%"
 
     return self.extra(
@@ -27,3 +26,6 @@ def question_search(self, keywords):
             order_by=['-ranking']
             )
 
             order_by=['-ranking']
             )
 
+
+
+