Advertisement
IncludeUrl

Untitled

Sep 16th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT
  2.     author,
  3.     message
  4. FROM
  5. (
  6.     SELECT
  7.         date,
  8.         pos,
  9.         author,
  10.         message,
  11.         ts_headline('russian', message, q, 'HighlightAll = true, StartSel = "", StopSel = ""') AS body
  12.     FROM
  13.         logs,
  14.         plainto_tsquery('russian', $1) AS q
  15.     WHERE
  16.         to_tsvector('russian', message) @@ q
  17.         AND NOT author = ANY ($2)
  18.     ORDER BY
  19.         ts_rank(to_tsvector('russian', message), q)
  20.         DESC
  21.     LIMIT 2000
  22. ) AS sq
  23. GROUP BY
  24.     author
  25. ORDER BY
  26.     count(message)
  27. LIMIT 5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement