Class: DorIndexing::Indexers::CollectionTitleIndexer

Inherits:
Object
  • Object
show all
Defined in:
lib/dor_indexing/indexers/collection_title_indexer.rb

Overview

Indexes collection titles for an object

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cocina:, parent_collections:) ⇒ CollectionTitleIndexer

Returns a new instance of CollectionTitleIndexer.



9
10
11
12
# File 'lib/dor_indexing/indexers/collection_title_indexer.rb', line 9

def initialize(cocina:, parent_collections:, **)
  @cocina = cocina
  @parent_collections = parent_collections
end

Instance Attribute Details

#cocinaObject (readonly)

Returns the value of attribute cocina.



7
8
9
# File 'lib/dor_indexing/indexers/collection_title_indexer.rb', line 7

def cocina
  @cocina
end

#parent_collectionsObject (readonly)

Returns the value of attribute parent_collections.



7
8
9
# File 'lib/dor_indexing/indexers/collection_title_indexer.rb', line 7

def parent_collections
  @parent_collections
end

Instance Method Details

#to_solrHash

Returns the partial solr document for collection title concerns.

Returns:

  • (Hash)

    the partial solr document for collection title concerns



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/dor_indexing/indexers/collection_title_indexer.rb', line 15

def to_solr
  {}.tap do |solr_doc|
    parent_collections.each do |collection_obj|
      coll_title = Cocina::Models::Builders::TitleBuilder.build(collection_obj.description.title)
      next if coll_title.blank?

      solr_doc['collection_title_ssim'] ||= []
      solr_doc['collection_title_ssim'] << coll_title
      solr_doc['collection_title_tesim'] ||= []
      solr_doc['collection_title_tesim'] << coll_title
    end
  end
end