summaryrefslogtreecommitdiffstats
path: root/forum_modules/pgfulltext/handlers.py
diff options
context:
space:
mode:
Diffstat (limited to 'forum_modules/pgfulltext/handlers.py')
-rwxr-xr-xforum_modules/pgfulltext/handlers.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/forum_modules/pgfulltext/handlers.py b/forum_modules/pgfulltext/handlers.py
new file mode 100755
index 00000000..17fb1762
--- /dev/null
+++ b/forum_modules/pgfulltext/handlers.py
@@ -0,0 +1,11 @@
+from forum.models import Question
+
+def question_search(keywords, orderby):
+ return Question.objects.filter(deleted=False).extra(
+ select={
+ 'ranking': "ts_rank_cd(tsv, plainto_tsquery(%s), 32)",
+ },
+ where=["tsv @@ plainto_tsquery(%s)"],
+ params=[keywords],
+ select_params=[keywords]
+ ).order_by(orderby, '-ranking') \ No newline at end of file