Skip to content

Instantly share code, notes, and snippets.

@NuckChorris
Created February 17, 2015 07:40
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 NuckChorris/5b3502a8a35882161a98 to your computer and use it in GitHub Desktop.
Save NuckChorris/5b3502a8a35882161a98 to your computer and use it in GitHub Desktop.
class Anime
pg_search_scope :search,
against: { title: 'A', alt_title: 'A', synopsis: 'C' },
using: {
tsearch: {
prefix: true,
# Normalize to string length and scale to 0..1
normalization: 32,
dictionary: 'english'
},
trigram: {
only: [:title, :alt_title],
}
},
# Combine trigram and tsearch values
ranked_by: ':trigram + :tsearch'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment