From 6c9b763b7ca1cd2f2e06fc0d42eaa6025552b0f2 Mon Sep 17 00:00:00 2001 From: hernani Date: Thu, 24 Jun 2010 23:24:42 +0000 Subject: [PATCH 1/1] Ultimate fix for the search query problem. git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@445 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- forum_modules/pgfulltext/handlers.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/forum_modules/pgfulltext/handlers.py b/forum_modules/pgfulltext/handlers.py index 6952758..5f18270 100644 --- a/forum_modules/pgfulltext/handlers.py +++ b/forum_modules/pgfulltext/handlers.py @@ -3,12 +3,11 @@ from django.db.models import Q 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): - 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( @@ -27,3 +26,6 @@ def question_search(self, keywords): order_by=['-ranking'] ) + + + -- 2.39.5