From 1c2263540e4fa1408a52fbc0ffe92faec499a4aa Mon Sep 17 00:00:00 2001 From: Chris Colvard Date: Mon, 12 Sep 2022 11:38:37 -0400 Subject: [PATCH] Index member_of_collection_ids for PcdmCollection Co-authored-by: Jose Blanco --- app/indexers/hyrax/pcdm_collection_indexer.rb | 1 + lib/hyrax/specs/shared_specs/indexers.rb | 5 +++++ spec/indexers/hyrax/pcdm_collection_indexer_spec.rb | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/indexers/hyrax/pcdm_collection_indexer.rb b/app/indexers/hyrax/pcdm_collection_indexer.rb index 6d20c88a32..14435278d3 100644 --- a/app/indexers/hyrax/pcdm_collection_indexer.rb +++ b/app/indexers/hyrax/pcdm_collection_indexer.rb @@ -16,6 +16,7 @@ def to_solr super.tap do |index_document| index_document[Hyrax.config.collection_type_index_field.to_sym] = Array(resource.try(:collection_type_gid)&.to_s) index_document[:generic_type_sim] = ['Collection'] + index_document[:member_of_collection_ids_ssim] = resource.member_of_collection_ids.map(&:to_s) index_document[:depositor_ssim] = [resource.depositor] index_document[:depositor_tesim] = [resource.depositor] end diff --git a/lib/hyrax/specs/shared_specs/indexers.rb b/lib/hyrax/specs/shared_specs/indexers.rb index 5e2c8d75de..592d928516 100644 --- a/lib/hyrax/specs/shared_specs/indexers.rb +++ b/lib/hyrax/specs/shared_specs/indexers.rb @@ -266,6 +266,11 @@ .to include(generic_type_sim: a_collection_containing_exactly('Collection')) end + it 'indexes member_of_collection_ids' do + expect(indexer.to_solr) + .to include(member_of_collection_ids_ssim: resource.member_of_collection_ids) + end + it 'indexes depositor' do expect(indexer.to_solr) .to include(depositor_ssim: [resource.depositor], diff --git a/spec/indexers/hyrax/pcdm_collection_indexer_spec.rb b/spec/indexers/hyrax/pcdm_collection_indexer_spec.rb index 083b762da4..09a47ae222 100644 --- a/spec/indexers/hyrax/pcdm_collection_indexer_spec.rb +++ b/spec/indexers/hyrax/pcdm_collection_indexer_spec.rb @@ -3,7 +3,7 @@ require 'hyrax/specs/shared_specs' RSpec.describe Hyrax::PcdmCollectionIndexer do - let(:resource) { FactoryBot.valkyrie_create(:hyrax_collection) } + let(:resource) { FactoryBot.valkyrie_create(:hyrax_collection, :as_collection_member) } let(:indexer_class) { described_class } it_behaves_like 'a Collection indexer'