Module: ActiveFedora::Indexing::ClassMethods

Defined in:
lib/active_fedora/indexing.rb

Instance Method Summary collapse

Instance Method Details

#load_instance_from_solr(pid, solr_doc = nil) ⇒ Object

This method can be used instead of ActiveFedora::Model::ClassMethods.find. It works similarly except it populates an object from Solr instead of Fedora. It is most useful for objects used in read-only displays in order to speed up loading time. If only a pid is passed in it will query solr for a corresponding solr document and then use it to populate this object.

If a value is passed in for optional parameter solr_doc it will not query solr again and just use the one passed to populate the object.

It will anything stored within solr such as metadata and relationships. Non-metadata datastreams will not be loaded and if needed you should use find instead.



84
85
86
# File 'lib/active_fedora/indexing.rb', line 84

def load_instance_from_solr(pid,solr_doc=nil)
  SolrInstanceLoader.new(self, pid, solr_doc).object
end

#reindex_everythingObject

Using the fedora search (not solr), get every object and reindex it.



89
90
91
92
93
94
95
# File 'lib/active_fedora/indexing.rb', line 89

def reindex_everything
  connections.each do |conn|
    conn.search(nil) do |object|
      ActiveFedora::Base.find(object.pid, :cast=>true).update_index
    end
  end
end