Skip to content
This repository has been archived by the owner on May 28, 2024. It is now read-only.

Commit

Permalink
Merge 5c03d39 into b80b674
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Jun 9, 2020
2 parents b80b674 + 5c03d39 commit 3a15e54
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions app/indexers/identifiable_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ class IdentifiableIndexer
'fedora' => 'info:fedora/fedora-system:def/relations-external#',
'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#' }.freeze

FIELDS = {
collection: {
hydrus: 'hydrus_collection_title',
non_hydrus: 'nonhydrus_collection_title',
union: 'collection_title'
},
apo: {
hydrus: 'hydrus_apo_title',
non_hydrus: 'nonhydrus_apo_title',
union: 'apo_title'
}
}
attr_reader :resource
def initialize(resource:)
@resource = resource
Expand All @@ -34,8 +46,8 @@ def to_solr
rels_doc = Nokogiri::XML(resource.datastreams['RELS-EXT'].content)
apos = rels_doc.search('//rdf:RDF/rdf:Description/hydra:isGovernedBy', NS_HASH)
collections = rels_doc.search('//rdf:RDF/rdf:Description/fedora:isMemberOfCollection', NS_HASH)
solrize_related_obj_titles(solr_doc, apos, @@apo_hash, 'apo_title', 'nonhydrus_apo_title', 'hydrus_apo_title')
solrize_related_obj_titles(solr_doc, collections, @@collection_hash, 'collection_title', 'nonhydrus_collection_title', 'hydrus_collection_title')
solrize_related_obj_titles(solr_doc, apos, @@apo_hash, :apo)
solrize_related_obj_titles(solr_doc, collections, @@collection_hash, :collection)
solr_doc['public_dc_relation_tesim'] ||= solr_doc['collection_title_tesim'] if solr_doc['collection_title_tesim']
solr_doc['metadata_source_ssi'] = identity_metadata_source
# This used to be added to the index by https://github.com/sul-dlss/dor-services/commit/11b80d249d19326ef591411ffeb634900e75c2c3
Expand Down Expand Up @@ -69,7 +81,11 @@ def related_object_tags(object)
Dor::Services::Client.object(object.pid).administrative_tags.list
end

def solrize_related_obj_titles(solr_doc, relationships, title_hash, union_field_name, nonhydrus_field_name, hydrus_field_name)
# @param [Hash] solr_doc
# @param [Array] relationships
# @param [Hash] title_hash a cache for titles
# @param [Symbol] type either :apo or :collection
def solrize_related_obj_titles(solr_doc, relationships, title_hash, type)
# TODO: if you wanted to get a little fancier, you could also solrize a 2 level hierarchy and display using hierarchial facets, like
# ["SOURCE", "SOURCE : TITLE"] (e.g. ["Hydrus", "Hydrus : Special Collections"], see (exploded) tags in IdentityMetadataDS#to_solr).
title_type = :symbol # we'll get an _ssim because of the type
Expand All @@ -95,11 +111,11 @@ def solrize_related_obj_titles(solr_doc, relationships, title_hash, union_field_

# cache should definitely be populated, so just use that to write solr field
if title_hash[rel_druid]['is_from_hydrus']
add_solr_value(solr_doc, hydrus_field_name, title_hash[rel_druid]['related_obj_title'], title_type, title_attrs)
add_solr_value(solr_doc, FIELDS.dig(type, :hydrus), title_hash[rel_druid]['related_obj_title'], title_type, title_attrs)
else
add_solr_value(solr_doc, nonhydrus_field_name, title_hash[rel_druid]['related_obj_title'], title_type, title_attrs)
add_solr_value(solr_doc, FIELDS.dig(type, :non_hydrus), title_hash[rel_druid]['related_obj_title'], title_type, title_attrs)
end
add_solr_value(solr_doc, union_field_name, title_hash[rel_druid]['related_obj_title'], title_type, title_attrs)
add_solr_value(solr_doc, FIELDS.dig(type, :union), title_hash[rel_druid]['related_obj_title'], title_type, title_attrs)
end
end

Expand Down

0 comments on commit 3a15e54

Please sign in to comment.