1 from django.db import connection, transaction
5 from django.db import connection, transaction, models
6 from django.db.models import Q
7 from forum.models.question import Question, QuestionManager
8 from forum.models.node import Node
9 from forum.modules import decorate
11 if not bool(settings.MYSQL_FTS_INSTALLED):
12 f = open(os.path.join(os.path.dirname(__file__), 'fts_install.sql'), 'r')
15 cursor = connection.cursor()
16 cursor.execute(f.read())
17 transaction.commit_unless_managed()
19 settings.MYSQL_FTS_INSTALLED.set_value(True)
22 #import sys, traceback
23 #traceback.print_exc(file=sys.stdout)
30 word_re = re.compile(r'\w+', re.UNICODE)
32 @decorate(QuestionManager.search, needs_origin=False)
33 def question_search(self, keywords):
34 return False, self.filter(models.Q(ftsindex__body__search=keywords.upper()))