Module: ActiveFedora::Indexing

Extended by:
ActiveSupport::Autoload, ActiveSupport::Concern, Deprecation
Included in:
Base
Defined in:
lib/active_fedora/indexing.rb,
lib/active_fedora/indexing/map.rb

Overview

Mix in this module to update Solr on save. Assign a new indexer at the class level where this is mixed in

(or define an #indexing_service method)
to change the document contents sent to solr

Example indexing services are:

Defined Under Namespace

Modules: ClassMethods Classes: Map

Instance Method Summary collapse

Instance Method Details

#indexing_serviceObject



37
38
39
# File 'lib/active_fedora/indexing.rb', line 37

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

#to_solr(_solr_doc = {}, _opts = {}) ⇒ Object

Return a Hash representation of this object where keys in the hash are appropriate Solr field names. If opts == true, the base object metadata and the RELS-EXT datastream will be omitted. This is mainly to support shelver, which calls #to_solr for each model an object subscribes to.

Parameters:

  • _solr_doc (Hash) (defaults to: {})

    (optional) Hash to insert the fields into

  • _opts (Hash) (defaults to: {})

    (optional)



33
34
35
# File 'lib/active_fedora/indexing.rb', line 33

def to_solr(_solr_doc = {}, _opts = {})
  indexing_service.generate_solr_document
end

#update_indexObject

Updates Solr index with self.



42
43
44
# File 'lib/active_fedora/indexing.rb', line 42

def update_index
  SolrService.add(to_solr, softCommit: true)
end