Sha256: 9b51b05071a60bd81fcfdc6730d2a7b6c78c83599ecdb7dcfb00bfbf04ebd325
Contents?: true
Size: 1.25 KB
Versions: 1
Compression:
Stored size: 1.25 KB
Contents
require 'search_context' class Varietal <ActiveRecord::Base include SearchContext::Methods attr_accessible :name # override the search_config if you are using some other search configuration def self.search_config "varietals_search_config" end def self.alias_search_config "varietals_alias_search_config" end # central place for queries using this search context, if it makes sense to share the search queries amoung multiple duck-typed models. # for example, BottleSource, Bottle, Wine all use similar vocabulary and search configuration. and queries module Query extend ActiveSupport::Concern included do # this example demostrates synonyms and stop words implemented via the aliases table, which you have to figure out # how to populate on your own scope :fuzzy_match, lambda {|term1| similar_terms= term1.split(/ +/).inject([]) do |acc, name| [name].concat(Varietal.similar_terms(name).uniq) end.flatten.join(' | ') where("ts_rewrite(to_tsquery(?,?),'select original_tsquery,substitution_tsquery from varietal_aliases WHERE to_tsquery('?','?') @>original_tsquery') @@ varietals_vector", Varietal.search_config,similar_terms, Varietal.search_config, similar_terms) } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
search_steroids-0.0.1 | spec/dummy/app/models/varietal.rb |