Module: Flare::ActiveRecord::ClassMethods
- Defined in:
- lib/flare/active_record.rb
Instance Method Summary collapse
- #clear_solr_index ⇒ Object
- #rebuild_solr_index ⇒ Object
- #search(*args) ⇒ Object
- #search_count(*args) ⇒ Object
- #search_for_ids(*args) ⇒ Object
- #searchable? ⇒ Boolean
Instance Method Details
#clear_solr_index ⇒ Object
71 72 73 |
# File 'lib/flare/active_record.rb', line 71 def clear_solr_index Flare.session.remove_all!(self) end |
#rebuild_solr_index ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/flare/active_record.rb', line 57 def rebuild_solr_index total = self.count count = 0 self.find_in_batches(:batch_size => 1000) do |batch| Flare.session.index(batch) count += batch.length printf "\r#{count}/#{total} complete" STDOUT.flush end puts Flare.session.commit Flare.session.optimize end |
#search(*args) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/flare/active_record.rb', line 38 def search(*args) = args. [:types] ||= [] [:types] << self Flare.session.search(*[args, ].flatten) end |
#search_count(*args) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/flare/active_record.rb', line 45 def search_count(*args) = args. .except!(:include) [:types] ||= [] [:types] << self Flare.session.count(*[args, ].flatten) end |
#search_for_ids(*args) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/flare/active_record.rb', line 30 def search_for_ids(*args) = args. .except!(:include) [:types] ||= [] [:types] << self Flare.session.search_for_ids(*[args, ].flatten) end |
#searchable? ⇒ Boolean
53 54 55 |
# File 'lib/flare/active_record.rb', line 53 def searchable? true end |