Skip to content

Instantly share code, notes, and snippets.

@ruckus
Created April 30, 2012 18:54
Show Gist options
  • Select an option

  • Save ruckus/2561258 to your computer and use it in GitHub Desktop.

Select an option

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