Advertisement
vojtarek

Full Text Search double ORDER pubtime

May 25th, 2011
591
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.57 KB | None | 0 0
  1. SELECT
  2. rank,
  3. --q as query,
  4. id,
  5. DATE,
  6. SOURCE,
  7. ts_headline('dutch', title, q) AS title,
  8. ts_headline('dutch', text, q) AS text
  9.  
  10. FROM (
  11.  
  12. SELECT
  13. ts_rank_cd(fts, q) AS rank,
  14. sources.SECTION AS SOURCE,
  15. documents.id,
  16. title,
  17. text,
  18. pubdate+pubtime AS DATE,
  19. q
  20.  
  21. FROM
  22. documents,
  23. sources,
  24. to_tsquery('dutch',
  25. '
  26. hämolytisch-urämische |
  27. EHEC-Darminfektionen |
  28. (EHEC & Darminfektionen) |
  29. Magen-Darm |
  30. Bauchschmerzen |
  31. (blutiger & Durchfall)
  32. '
  33. ) q
  34.  
  35. WHERE
  36. sources.id=documents.source_id AND
  37. documents.fts @@ q
  38. AND documents.LANGUAGE='de'
  39. ORDER BY rank DESC
  40. LIMIT 800
  41. ) AS foo
  42.  
  43. ORDER BY DATE DESC;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement