]> git.openstreetmap.org Git - osqa.git/blob - forum_modules/pgfulltext/handlers.py
Initial commit
[osqa.git] / forum_modules / pgfulltext / handlers.py
1 from forum.models import Question\r
2 \r
3 def question_search(keywords, orderby):\r
4     return Question.objects.filter(deleted=False).extra(\r
5                     select={\r
6                         'ranking': "ts_rank_cd(tsv, plainto_tsquery(%s), 32)",\r
7                     },\r
8                     where=["tsv @@ plainto_tsquery(%s)"],\r
9                     params=[keywords],\r
10                     select_params=[keywords]\r
11                 ).order_by(orderby, '-ranking')