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

Dual boot solrizer #745

Merged
merged 3 commits into from
Aug 9, 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
10 changes: 10 additions & 0 deletions app/helpers/solr_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# app/helpers/solr_helper.rb
module SolrHelper
def solr_name(field_name, *opts)
if Module.const_defined?(:Solrizer)
Copy link
Collaborator Author

@ShanaLMoore ShanaLMoore Aug 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not using the dual boot support #rails_5_1? helper method here because that wouldn't necessarily be a valid check.

::Solrizer.solr_name(field_name, *opts)
else
::ActiveFedora.index_field_mapper.solr_name(field_name)
end
end
end
6 changes: 4 additions & 2 deletions app/indexers/ams/work_indexer.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module AMS
class WorkIndexer < Hyrax::WorkIndexer
include SolrHelper

def generate_solr_document
find_index_child_attributes(super)
end
Expand All @@ -13,9 +15,9 @@ def find_index_child_attributes(solr_doc)
parent_indexable_properties = work_type.properties.select{|index,val| val["index_to_parent"]||index=="language"||index=="contributor"?true:false}
parent_indexable_properties.each do |prop, config|
solr_doc["#{work_type.to_s.underscore}_#{prop}_ssim"] ||= []
solr_doc["#{work_type.to_s.underscore}_#{prop}_ssim"] |= work[Solrizer.solr_name(prop)] if work[Solrizer.solr_name(prop)]
solr_doc["#{work_type.to_s.underscore}_#{prop}_ssim"] |= work[solr_name(prop)] if work[solr_name(prop)]
solr_doc["#{prop}_ssim"] ||= []
solr_doc["#{prop}_ssim"] |= work[Solrizer.solr_name(prop)] if work[Solrizer.solr_name(prop)]
solr_doc["#{prop}_ssim"] |= work[solr_name(prop)] if work[solr_name(prop)]
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions app/indexers/asset_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def generate_solr_document
solr_doc['broadcast_date_drsim'] = object.broadcast_date if object.broadcast_date
solr_doc['created_date_drsim'] = object.created_date if object.created_date
solr_doc['copyright_date_drsim'] = object.copyright_date if object.copyright_date
solr_doc[Solrizer.solr_name('bulkrax_identifier', :facetable)] = object.bulkrax_identifier
solr_doc[solr_name('bulkrax_identifier', :facetable)] = object.bulkrax_identifier
solr_doc['intended_children_count_isi'] = object.intended_children_count.to_i

if object.admin_data
Expand All @@ -29,7 +29,7 @@ def generate_solr_document
AnnotationTypesService.new.select_all_options.each do |type|
# Use the ID defined in the AnnotationType service
type_id = type[1]
solr_doc[ Solrizer.solr_name(type_id.underscore,'ssim') ] = object.try(type_id.to_sym) unless object.try(type_id.to_sym).empty?
solr_doc[ solr_name(type_id.underscore,'ssim') ] = object.try(type_id.to_sym) unless object.try(type_id.to_sym).empty?
end

#Indexing for search by batch_id
Expand Down
2 changes: 1 addition & 1 deletion app/indexers/digital_instantiation_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class DigitalInstantiationIndexer < AMS::WorkIndexer

def generate_solr_document
super.tap do |solr_doc|
solr_doc[Solrizer.solr_name('bulkrax_identifier', :facetable)] = object.bulkrax_identifier
solr_doc[solr_name('bulkrax_identifier', :facetable)] = object.bulkrax_identifier
if object.instantiation_admin_data
#Indexing as english text so we can use it on asset show page
solr_doc['instantiation_admin_data_tesim'] = object.instantiation_admin_data.gid if !object.instantiation_admin_data.gid.blank?
Expand Down
2 changes: 1 addition & 1 deletion app/indexers/essence_track_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class EssenceTrackIndexer < AMS::WorkIndexer
# Uncomment this block if you want to add custom indexing behavior:
def generate_solr_document
super.tap do |solr_doc|
solr_doc[Solrizer.solr_name('bulkrax_identifier', :facetable)] = object.bulkrax_identifier
solr_doc[solr_name('bulkrax_identifier', :facetable)] = object.bulkrax_identifier
end
end
end
2 changes: 1 addition & 1 deletion app/indexers/physical_instantiation_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class PhysicalInstantiationIndexer < AMS::WorkIndexer

def generate_solr_document
super.tap do |solr_doc|
solr_doc[Solrizer.solr_name('bulkrax_identifier', :facetable)] = object.bulkrax_identifier
solr_doc[solr_name('bulkrax_identifier', :facetable)] = object.bulkrax_identifier
if object.instantiation_admin_data
#Indexing as english text so we can use it on asset show page
solr_doc['instantiation_admin_data_tesim'] = object.instantiation_admin_data.gid if !object.instantiation_admin_data.gid.blank?
Expand Down
3 changes: 2 additions & 1 deletion app/models/asset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class Asset < ActiveFedora::Base
include ::AMS::IdentifierService
include ::AMS::CascadeDestroyMembers
include ::AMS::AllMembers
include SolrHelper

# @see Push#add_status_error
VALIDATION_STATUSES = {
Expand Down Expand Up @@ -230,7 +231,7 @@ def admin_data_gid=(new_admin_data_gid)
end

def admin_data_gid_document_field_name
Solrizer.solr_name('admin_data_gid', *index_admin_data_gid_as)
solr_name('admin_data_gid', *index_admin_data_gid_as)
end

def sonyci_id
Expand Down
Loading