Class: DorIndexing::Indexers::AdministrativeTagIndexer
- Inherits:
-
Object
- Object
- DorIndexing::Indexers::AdministrativeTagIndexer
- Defined in:
- lib/dor_indexing/indexers/administrative_tag_indexer.rb
Overview
Index administrative tags for an object
Constant Summary collapse
- TAG_PART_DELIMITER =
' : '
- SPECIAL_TAG_TYPES_TO_INDEX =
['Project', 'Registered By'].freeze
Instance Attribute Summary collapse
-
#administrative_tags ⇒ Object
readonly
Returns the value of attribute administrative_tags.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
-
#initialize(id:, administrative_tags:) ⇒ AdministrativeTagIndexer
constructor
A new instance of AdministrativeTagIndexer.
-
#to_solr ⇒ Hash
rubocop:disable Metrics/MethodLength rubocop:disable Metrics/AbcSize rubocop:disable Metrics/CyclomaticComplexity.
Constructor Details
#initialize(id:, administrative_tags:) ⇒ AdministrativeTagIndexer
Returns a new instance of AdministrativeTagIndexer.
12 13 14 15 |
# File 'lib/dor_indexing/indexers/administrative_tag_indexer.rb', line 12 def initialize(id:, administrative_tags:, **) @id = id @administrative_tags = end |
Instance Attribute Details
#administrative_tags ⇒ Object (readonly)
Returns the value of attribute administrative_tags.
10 11 12 |
# File 'lib/dor_indexing/indexers/administrative_tag_indexer.rb', line 10 def @administrative_tags end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
10 11 12 |
# File 'lib/dor_indexing/indexers/administrative_tag_indexer.rb', line 10 def id @id end |
Instance Method Details
#to_solr ⇒ Hash
rubocop:disable Metrics/MethodLength rubocop:disable Metrics/AbcSize rubocop:disable Metrics/CyclomaticComplexity
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/dor_indexing/indexers/administrative_tag_indexer.rb', line 21 def to_solr solr_doc = { 'tag_ssim' => [], 'tag_text_unstemmed_im' => [], 'exploded_nonproject_tag_ssim' => [] } .each do |tag| tag_prefix, rest = tag.split(TAG_PART_DELIMITER, 2) prefix = tag_prefix.downcase.strip.gsub(/\s/, '_') solr_doc['tag_ssim'] << tag # for Argo display and fq solr_doc['tag_text_unstemmed_im'] << tag # for Argo search # exploded tags are for hierarchical facets in Argo solr_doc['exploded_nonproject_tag_ssim'] += explode_tag_hierarchy(tag) unless prefix == 'project' next if rest.blank? # Index specific tag types that are used in Argo: # project tags for search results and registered by tags for reports ... next unless SPECIAL_TAG_TYPES_TO_INDEX.include?(tag_prefix) (solr_doc["#{prefix}_tag_ssim"] ||= []) << rest.strip if prefix == 'project' solr_doc['exploded_project_tag_ssim'] ||= [] solr_doc['exploded_project_tag_ssim'] += explode_tag_hierarchy(rest.strip) end end solr_doc end |