Skip to content

Commit

Permalink
Replaces Solrizer with Active:Fedora::Indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Scherz committed Mar 21, 2024
1 parent a1a0149 commit 8e2f744
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 21 deletions.
2 changes: 1 addition & 1 deletion app/indexers/hyrax/collection_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def generate_solr_document
solr_doc[ActiveFedora.index_field_mapper.solr_name(:bytes, STORED_LONG)] = object.bytes
solr_doc['thumbnail_path_ss'] = thumbnail_path
solr_doc['visibility_ssi'] = object.visibility
Solrizer.insert_field(solr_doc, 'sort_title', sortable_title(object.title.first), :stored_sortable) if object.title.present?
# Solrizer.insert_field(solr_doc, 'sort_title', sortable_title(object.title.first), :stored_sortable) if object.title.present?

object.in_collections.each do |col|
(solr_doc['member_of_collection_ids_ssim'] ||= []) << col.id
Expand Down
8 changes: 5 additions & 3 deletions app/indexers/hyrax/work_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,21 @@ def generate_solr_document
solr_doc['member_ids_ssim'] = object.member_ids
solr_doc['member_of_collections_ssim'] = object.member_of_collections.map(&:first_title)
solr_doc['member_of_collection_ids_ssim'] = object.member_of_collections.map(&:id)
Solrizer.set_field(solr_doc, 'generic_type', 'Work', :facetable)
# solr_doc['generic_type_sim'] = ['Work']
ActiveFedora.index_field_mapper.set_field(solr_doc, 'generic_type', 'Work', :facetable)

# This enables us to return a Work when we have a FileSet that matches
# the search query. While at the same time allowing us not to return Collections
# when a work in the collection matches the query.
solr_doc['file_set_ids_ssim'] = solr_doc['member_ids_ssim']
solr_doc['visibility_ssi'] = object.visibility
solr_doc[Solrizer.solr_name('date_created', :facetable)] = object.date_created
solr_doc[ActiveFedora.index_field_mapper.solr_name('date_created', :facetable)] = object.date_created

admin_set_label = object.admin_set.to_s
solr_doc['admin_set_sim'] = admin_set_label
solr_doc['admin_set_tesim'] = admin_set_label
Solrizer.insert_field(solr_doc, 'sort_title', sortable_title(object.title.first), :stored_sortable) if object.title.present?
# Still need to figure out how to remove Solrizer
# ActiveFedora.index_field_mapper.insert_field(solr_doc, 'sort_title', sortable_title(object.title.first), :stored_sortable) if object.title.present?
end
end
end
Expand Down
6 changes: 6 additions & 0 deletions app/models/basic_collection_metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ module BasicCollectionMetadata
property :creator, predicate: ::RDF::Vocab::DC11.creator
property :contributor, predicate: ::RDF::Vocab::DC11.contributor

# added with hyrax 3.0
property :alternative_title, predicate: ::RDF::Vocab::DC.alternative
property :abstract, predicate: ::RDF::Vocab::DC.abstract
property :rights_notes, predicate: ::RDF::URI.new('http://purl.org/dc/elements/1.1/rights'), multiple: true
property :access_right, predicate: ::RDF::Vocab::DC.accessRights

# override the predicate for description to match past versions of Scholar
property :description, predicate: ::RDF::Vocab::DC11.description
property :publisher, predicate: ::RDF::Vocab::DC11.publisher
Expand Down
6 changes: 6 additions & 0 deletions app/models/concerns/hyrax/basic_metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ module BasicMetadata
# override the predicate for description to match past versions of Scholar
property :description, predicate: ::RDF::URI.new('http://purl.org/dc/terms/description')

# added with hyrax 3.0
property :alternative_title, predicate: ::RDF::Vocab::DC.alternative
property :abstract, predicate: ::RDF::Vocab::DC.abstract
property :rights_notes, predicate: ::RDF::URI.new('http://purl.org/dc/elements/1.1/rights'), multiple: true
property :access_right, predicate: ::RDF::Vocab::DC.accessRights

property :keyword, predicate: ::RDF::Vocab::DC11.relation
# Used for a license
property :license, predicate: ::RDF::Vocab::DC.rights
Expand Down
46 changes: 30 additions & 16 deletions app/models/solr_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,75 +25,89 @@ class SolrDocument

use_extension(Hydra::ContentNegotiation)

# Added for Hyrax 3

def alternative_title
self[ActiveFedora.index_field_mapper.solr_name('alternate_title')]
end

def abstract
self[ActiveFedora.index_field_mapper.solr_name('abstract')]
end

def rights_notes
self[ActiveFedora.index_field_mapper.solr_name('rights_notes')]
end

# Added for All Work Types

def alternate_title
self[Solrizer.solr_name('alternate_title')]
self[ActiveFedora.index_field_mapper.solr_name('alternate_title')]
end

def advisor
self[Solrizer.solr_name('advisor')]
self[ActiveFedora.index_field_mapper.solr_name('advisor')]
end

def committee_member
self[Solrizer.solr_name('committee_member')]
self[ActiveFedora.index_field_mapper.solr_name('committee_member')]
end

def required_software
self[Solrizer.solr_name('required_software')]
self[ActiveFedora.index_field_mapper.solr_name('required_software')]
end

def time_period
self[Solrizer.solr_name('time_period')]
self[ActiveFedora.index_field_mapper.solr_name('time_period')]
end

def note
self[Solrizer.solr_name('note')]
self[ActiveFedora.index_field_mapper.solr_name('note')]
end

# Added for Article Work Type

def journal_title
self[Solrizer.solr_name('journal_title')]
self[ActiveFedora.index_field_mapper.solr_name('journal_title')]
end

def issn
self[Solrizer.solr_name('issn')]
self[ActiveFedora.index_field_mapper.solr_name('issn')]
end

# Added for StudentWork, Document, and Image work types

def genre
self[Solrizer.solr_name('genre')]
self[ActiveFedora.index_field_mapper.solr_name('genre')]
end

def geo_subject
self[Solrizer.solr_name('geo_subject')]
self[ActiveFedora.index_field_mapper.solr_name('geo_subject')]
end

def degree
self[Solrizer.solr_name('degree')]
self[ActiveFedora.index_field_mapper.solr_name('degree')]
end

# Complex metadata fields that we be implemented later.

# def doi
# self[Solrizer.solr_name('doi')]
# self[ActiveFedora.index_field_mapper.solr_name('doi')]
# end

def college
self[Solrizer.solr_name('college')]
self[ActiveFedora.index_field_mapper.solr_name('college')]
end

def department
self[Solrizer.solr_name('department')]
self[ActiveFedora.index_field_mapper.solr_name('department')]
end

def doi
self[Solrizer.solr_name('doi')]
self[ActiveFedora.index_field_mapper.solr_name('doi')]
end

def etd_publisher
self[Solrizer.solr_name('etd_publisher')]
self[ActiveFedora.index_field_mapper.solr_name('etd_publisher')]
end
end
2 changes: 1 addition & 1 deletion spec/views/hyrax/base/_attributes.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
let(:solr_document) { SolrDocument.new(attributes) }
let(:attributes) do
{
Solrizer.solr_name('has_model', :symbol) => ["GenericWork"],
ActiveFedora.index_field_mapper.solr_name('has_model', :symbol) => ["GenericWork"],
college_tesim: college,
department_tesim: department,
related_url_tesim: related_url,
Expand Down

0 comments on commit 8e2f744

Please sign in to comment.