module ActiveFedora::Indexing

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?
  ENABLE_SOLR_UPDATES
end

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 indexing_service

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

def to_solr(solr_doc = Hash.new, opts={})

Parameters:
  • opts (Hash) -- (optional)
  • solr_doc (Hash) -- (optional) Hash to insert the fields into
def to_solr(solr_doc = Hash.new, 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?
  ENABLE_SOLR_UPDATES
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