Skip to content

Instantly share code, notes, and snippets.

@ruckus
Created April 30, 2012 18:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ruckus/2561258 to your computer and use it in GitHub Desktop.
Save ruckus/2561258 to your computer and use it in GitHub Desktop.
SELECT varietals.*, ts_rank_cd(varietals.search_content, plainto_tsquery('vinosmith', 'gruner')) as rank
FROM varietals WHERE varietals.search_content @@ plainto_tsquery('vinosmith', 'gruner')
ORDER BY rank DESC limit 25
=> [#<Varietal id: 657, name: "Grüner Veltliner" .. ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment