Module: Flare::ActiveRecord::ClassMethods

Defined in:
lib/flare/active_record.rb

Instance Method Summary collapse

Instance Method Details

#clear_solr_indexObject



71
72
73
# File 'lib/flare/active_record.rb', line 71

def clear_solr_index
  Flare.session.remove_all!(self)
end

#rebuild_solr_indexObject



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)
  options = args.extract_options!
  options[:types] ||= []
  options[:types] << self
  Flare.session.search(*[args, options].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)
  options = args.extract_options!
  options.except!(:include)
  options[:types] ||= []
  options[:types] << self
  Flare.session.count(*[args, options].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)
  options = args.extract_options!
  options.except!(:include)
  options[:types] ||= []
  options[:types] << self
  Flare.session.search_for_ids(*[args, options].flatten)
end

#searchable?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/flare/active_record.rb', line 53

def searchable?
  true
end