Module: ActiveFedora::Indexing

Extended by:
ActiveSupport::Autoload, ActiveSupport::Concern
Included in:
Base
Defined in:
lib/active_fedora/indexing.rb,
lib/active_fedora/indexing/map.rb,
lib/active_fedora/indexing/suffix.rb,
lib/active_fedora/indexing/inserter.rb,
lib/active_fedora/indexing/descriptor.rb,
lib/active_fedora/indexing/field_mapper.rb,
lib/active_fedora/indexing/descendant_fetcher.rb,
lib/active_fedora/indexing/default_descriptors.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: DefaultDescriptors, DescendantFetcher, Descriptor, FieldMapper, Inserter, Map, Suffix

Instance Method Summary collapse

Instance Method Details

#indexing_serviceObject



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

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)



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

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

#update_indexObject

Updates Solr index with self.



47
48
49
# File 'lib/active_fedora/indexing.rb', line 47

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