Class: Spotlight::Resources::DorSolrDocumentBuilder

Inherits:
SolrDocumentBuilder
  • Object
show all
Includes:
ActiveSupport::Benchmarkable
Defined in:
app/services/spotlight/resources/dor_solr_document_builder.rb

Overview

Base Resource indexer for objects in DOR

Instance Method Summary collapse

Instance Method Details

#to_solrEnumerator

Generate solr documents for the DOR resources identified by this object

Returns:

  • (Enumerator)

    an enumerator of solr document hashes for indexing



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/services/spotlight/resources/dor_solr_document_builder.rb', line 13

def to_solr
  return to_enum(:to_solr) { size } unless block_given?

  benchmark "Indexing resource #{inspect} (est. #{size} items)" do
    base_doc = super

    indexable_resources.each_with_index do |res, idx|
      benchmark "Indexing item #{res.druid} in resource #{resource_id} (#{idx} / #{size})" do
        doc = to_solr_document(res)
        yield base_doc.merge(doc) if doc
      end
    end
  end
end