Sha256: 9b26d82b157aefccecc0536fe72481a0f0922d4f8cd8eb411cfcdd33519ebf09
Contents?: true
Size: 1.28 KB
Versions: 1
Compression:
Stored size: 1.28 KB
Contents
require 'search_context' class Name <ActiveRecord::Base include SearchContext::Methods attr_accessible :count, :name # override the search_config if you are using some other search configuration def self.search_config "names_search_config" end def self.alias_search_config "names_alias_search_config" end def self.similarity_limit 0.27 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(Name.similar_terms(name).uniq) end.flatten.join(' | ') where("ts_rewrite(to_tsquery(?,?),'select original_tsquery,substitution_tsquery from name_aliases WHERE to_tsquery('?','?') @>original_tsquery') @@ names_vector", Name.search_config,similar_terms, Name.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/name.rb |