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

Commit

Permalink
Merge 834770e into 08ad7ee
Browse files Browse the repository at this point in the history
  • Loading branch information
jcoyne committed Jun 5, 2020
2 parents 08ad7ee + 834770e commit 2602671
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
11 changes: 4 additions & 7 deletions app/indexers/administrative_tag_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# https://github.com/sul-dlss/dor-services/blob/v9.0.0/lib/dor/datastreams/identity_metadata_ds.rb#L196-L218
class AdministrativeTagIndexer
TAG_PART_DELIMITER = ' : '
TAGS_TO_INDEX = ['Project', 'Registered By'].freeze

attr_reader :resource

Expand All @@ -20,14 +21,10 @@ def to_solr
solr_doc['exploded_tag_ssim'] ||= []
solr_doc['exploded_tag_ssim'] += exploded_tags_from(tag)

# this part will index a value in a field specific to the tag, e.g. registered_by_tag_*,
# book_tag_*, project_tag_*, remediated_by_tag_*, etc. project_tag_* and registered_by_tag_*
# definitely get used, but most don't. we can limit the prefixes that get solrized if things
# get out of hand.
prefix, rest = tag.split(TAG_PART_DELIMITER, 2)
prefix = prefix.downcase.strip.gsub(/\s/, '_')
next if rest.nil?
tag_prefix, rest = tag.split(TAG_PART_DELIMITER, 2)
next if !TAGS_TO_INDEX.include?(tag_prefix) || rest.nil?

prefix = tag_prefix.downcase.strip.gsub(/\s/, '_')
(solr_doc["#{prefix}_tag_ssim"] ||= []) << rest.strip
end
solr_doc
Expand Down
5 changes: 1 addition & 4 deletions spec/indexers/administrative_tag_indexer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,8 @@

it 'indexes prefixed tags' do
expect(document).to include(
'google_books_tag_ssim' => ['Phase 1', 'Scan source STANFORD'],
'project_tag_ssim' => ['Beautiful Books'],
'registered_by_tag_ssim' => ['blalbrit'],
'dpg_tag_ssim' => ['Beautiful Books : Octavo : newpri'],
'remediated_by_tag_ssim' => ['4.15.4']
'registered_by_tag_ssim' => ['blalbrit']
)
end
end
Expand Down

0 comments on commit 2602671

Please sign in to comment.