Module: Searchkick::Similar
- Defined in:
- lib/searchkick/similar.rb
Instance Method Summary collapse
Instance Method Details
#similar(options = {}) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/searchkick/similar.rb', line 4 def similar( = {}) like_text = self.class.searchkick_index.retrieve(document_type, id).to_hash .keep_if{|k,v| k[0] != "_" and (![:fields] or [:fields].map(&:to_sym).include?(k)) } .values.compact.join(" ") # TODO deep merge method [:where] ||= {} [:where][:_id] ||= {} [:where][:_id][:not] = id.to_s [:limit] ||= 10 [:similar] = true self.class.search(like_text, ) end |