Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix indexing of children #813

Merged
merged 2 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ GIT

GIT
remote: https://github.com/samvera/hyrax.git
revision: 0108fed6c83dd4a449b37cc1a6c19787ec54921d
revision: b7891b758411c59f71ff54212e0d250fcc47e35f
branch: double_combo
specs:
hyrax (5.0.0.rc2)
Expand Down
26 changes: 26 additions & 0 deletions app/indexers/ams/valkyrie_work_indexer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module AMS
class ValkyrieWorkIndexer < Hyrax::ValkyrieWorkIndexer
include SolrHelper

def to_solr
find_index_child_attributes(super)
end

private
def find_index_child_attributes(solr_doc)
resource.members.each do |child|
parent_indexable_properties = [ "language", "contributor"]
child.class.fields.each do |field_name|
parent_indexable_properties << field_name if child.class.schema.key(field_name).meta['index_to_parent']
end
parent_indexable_properties.uniq.each do |prop|
solr_doc["#{child.class.to_s.underscore}_#{prop}_ssim"] ||= []
solr_doc["#{child.class.to_s.underscore}_#{prop}_ssim"] |= Array.wrap(child.send(prop))
solr_doc["#{prop}_ssim"] ||= []
solr_doc["#{prop}_ssim"] |= Array.wrap(child.send(prop))
end
end
solr_doc
end
end
end
2 changes: 1 addition & 1 deletion app/indexers/ams/work_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ def find_index_child_attributes(solr_doc)
solr_doc
end
end
end
end
2 changes: 1 addition & 1 deletion app/indexers/asset_resource_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Generated via
# `rails generate hyrax:work_resource AssetResource`
class AssetResourceIndexer < Hyrax::ValkyrieWorkIndexer
class AssetResourceIndexer < AMS::ValkyrieWorkIndexer
include Hyrax::Indexer(:basic_metadata)
include Hyrax::Indexer(:asset_resource)

Expand Down
2 changes: 1 addition & 1 deletion app/indexers/contribution_resource_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Generated via
# `rails generate hyrax:work_resource ContributionResource`
class ContributionResourceIndexer < Hyrax::ValkyrieWorkIndexer
class ContributionResourceIndexer < AMS::ValkyrieWorkIndexer
include Hyrax::Indexer(:basic_metadata)
include Hyrax::Indexer(:contribution_resource)

Expand Down
2 changes: 1 addition & 1 deletion app/indexers/digital_instantiation_resource_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Generated via
# `rails generate hyrax:work_resource DigitalInstantiationResource`
class DigitalInstantiationResourceIndexer < Hyrax::ValkyrieWorkIndexer
class DigitalInstantiationResourceIndexer < AMS::ValkyrieWorkIndexer
include Hyrax::Indexer(:basic_metadata)
include Hyrax::Indexer(:digital_instantiation_resource)

Expand Down
2 changes: 1 addition & 1 deletion app/indexers/essence_track_resource_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Generated via
# `rails generate hyrax:work_resource EssenceTrackResource`
class EssenceTrackResourceIndexer < Hyrax::ValkyrieWorkIndexer
class EssenceTrackResourceIndexer < AMS::ValkyrieWorkIndexer
include Hyrax::Indexer(:basic_metadata)
include Hyrax::Indexer(:essence_track_resource)

Expand Down
2 changes: 1 addition & 1 deletion app/indexers/physical_instantiation_resource_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Generated via
# `rails generate hyrax:work_resource PhysicalInstantiationResource`
class PhysicalInstantiationResourceIndexer < Hyrax::ValkyrieWorkIndexer
class PhysicalInstantiationResourceIndexer < AMS::ValkyrieWorkIndexer
include Hyrax::Indexer(:basic_metadata)
include Hyrax::Indexer(:physical_instantiation_resource)

Expand Down
4 changes: 2 additions & 2 deletions app/presenters/aapb/instantiation_admin_data_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ def attribute_to_html(field, options = {})
options.merge!({:html_dl=> true})

solr_document = ::SolrDocument.find(id)
old_models = ['Asset', 'PhysicalInstantiation', 'DigitalInstantiation', 'Contribution']
work_class = old_models.include?(solr_document['has_model_ssim'].first) ? "#{solr_document['has_model_ssim'].first}Resource" : solr_document['has_model_ssim'].first
work_class = solr_document['has_model_ssim'].first
work_class = work_class.constantize
work_class = Wings::ModelRegistry.reverse_lookup(work_class) || work_class

if attribute_indexed_to_parent?(field, work_class) && attribute_facetable?(field, work_class)
# Use :symbol for field_name since all attributes indexed to parent are indexed as symbols.
Expand Down
1 change: 1 addition & 0 deletions config/metadata/.#physical_instantiation_resource.yaml
2 changes: 2 additions & 0 deletions config/metadata/contribution_resource.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ attributes:
portrayal:
type: string
multiple: false
index_to_parent: true
index_keys:
- "portrayal_tesim"
form:
Expand All @@ -47,6 +48,7 @@ attributes:
affiliation:
type: string
multiple: false
index_to_parent: true
index_keys:
- "affiliation_tesim"
form:
Expand Down
5 changes: 5 additions & 0 deletions config/metadata/digital_instantiation_resource.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ attributes:
date:
type: string
multiple: true
index_to_parent: true
index_keys:
- "date_sim"
- "date_tesim"
Expand Down Expand Up @@ -79,6 +80,7 @@ attributes:
media_type:
type: string
multiple: false
index_to_parent: true
index_keys:
- "media_type_sim"
- "media_type_tesim"
Expand All @@ -89,6 +91,7 @@ attributes:
generations:
type: string
multiple: true
index_to_parent: true
index_keys:
- "generations_sim"
- "generations_tesim"
Expand Down Expand Up @@ -171,6 +174,7 @@ attributes:
local_instantiation_identifier:
type: string
multiple: true
index_to_parent: true
index_keys:
- "local_instantiation_identifier_tesim"
form:
Expand Down Expand Up @@ -207,6 +211,7 @@ attributes:
holding_organization:
type: string
multiple: false
index_to_parent: true
index_keys:
- "holding_organization_sim"
- "holding_organization_tesim"
Expand Down
4 changes: 4 additions & 0 deletions config/metadata/physical_instantiation_resource.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ attributes:
date:
type: string
multiple: true
index_to_parent: true
index_keys:
- "date_sim"
- "date_tesim"
Expand Down Expand Up @@ -61,6 +62,7 @@ attributes:
format:
type: string
multiple: false
index_to_parent: true
index_keys:
- "format_tesim"
form:
Expand Down Expand Up @@ -88,6 +90,7 @@ attributes:
media_type:
type: string
multiple: false
index_to_parent: true
index_keys:
- "media_type_sim"
- "media_type_tesim"
Expand Down Expand Up @@ -162,6 +165,7 @@ attributes:
local_instantiation_identifier:
type: string
multiple: true
index_to_parent: true
index_keys:
- "local_instantiation_identifier_tesim"
form:
Expand Down
3 changes: 1 addition & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ services:
environment:
- VIRTUAL_PORT=3000
- VIRTUAL_HOST=.ams.test
# command: sh -l -c "bundle && bundle exec puma -v -b tcp://0.0.0.0:3000"
# command: sh -l -c "sleep infinity"
cap_add:
- SYS_PTRACE
depends_on:
Expand All @@ -237,7 +237,6 @@ services:
condition: service_started
initialize_app:
condition: service_completed_successfully

expose:
- 3000

Expand Down
Loading