1 from django.db.models import Q
2 from forum.models.question import Question, QuestionManager
3 from forum.modules.decorators import decorate
5 @decorate(QuestionManager.search, needs_origin=False)
6 def question_search(self, keywords):
7 tsquery = " | ".join(keywords.split(' '))
10 tables = ['forum_rootnode_doc'],
13 rank_exact_matches(ts_rank_cd('{0.1, 0.2, 0.8, 1.0}'::float4[], "forum_rootnode_doc"."document", to_tsquery('english', %s), 32))
17 "forum_rootnode_doc"."node_id" = "forum_node"."id" AND ("forum_rootnode_doc"."document" @@ to_tsquery('english', %s) OR
18 "forum_node"."title" ILIKE '""" + keywords + """%%')
21 select_params=[tsquery],