module ActiveFedora::Indexing

def _create_record(options = {})

index the record after it has been persisted to Fedora
def _create_record(options = {})
  super
  update_index if create_needs_index? && options.fetch(:update_index, true)
  true
end

def _update_record(options = {})

index the record after it has been updated in Fedora
def _update_record(options = {})
  super
  update_index if update_needs_index? && options.fetch(:update_index, true)
  true
end

def create_needs_index?

Override this if you need different behavior.
Determines whether a create operation causes a solr index of this object by default.
def create_needs_index?
  ActiveFedora.enable_solr_updates?
end

def indexing_service

def indexing_service
  @indexing_service ||= self.class.indexer.new(self)
end

def to_solr(_solr_doc = {}, _opts = {})

Parameters:
  • _opts (Hash) -- (optional)
  • _solr_doc (Hash) -- (optional) Hash to insert the fields into
def to_solr(_solr_doc = {}, _opts = {})
  indexing_service.generate_solr_document
end

def update_index

Updates Solr index with self.
def update_index
  SolrService.add(to_solr, softCommit: true)
end

def update_needs_index?

Override this if you need different behavior
Determines whether an update operation causes a solr index of this object by default.
def update_needs_index?
  ActiveFedora.enable_solr_updates?
end