Module: ActsAsFerret::MoreLikeThis::IndexMethods

Included in:
LocalIndex
Defined in:
lib/acts_as_ferret/more_like_this.rb

Instance Method Summary collapse

Instance Method Details

#build_more_like_this_query(key, id, options) ⇒ Object

TODO to allow morelikethis for unsaved records, we have to give the unsaved record’s data to this method. check how this will work out via drb…



66
67
68
69
70
71
72
73
74
75
# File 'lib/acts_as_ferret/more_like_this.rb', line 66

def build_more_like_this_query(key, id, options)
  [:similarity, :analyzer].each { |sym| options[sym] = options[sym].constantize.new }
  ferret_index.synchronize do # avoid that concurrent writes close our reader
    ferret_index.send(:ensure_reader_open)
    reader = ferret_index.send(:reader)
    term_freq_map = retrieve_terms(key, id, reader, options)
    priority_queue = create_queue(term_freq_map, reader, options)
    create_query(key, priority_queue, options)
  end
end