app/indexers/work_indexer.rb
# Uncomment this block if you want to add custom indexing behavior:
Uncomment this block if you want to add custom indexing behavior.
Uncomment this block if you want to add custom indexing behavior .
def generate_solr_document
    object.attribute_names.each do |field|
      if object.controlled_properties.include?(field.to_sym) and object[field].present?
        to_controlled_vocab(field)
      end
    end
    super.tap do |solr_doc|
      if object.thumbnail and object.thumbnail.files.any?
        if object.thumbnail.audio? or object.thumbnail.files.first.file_name.first.include?(".m4a")
          solr_doc['thumbnail_path_ss'] = AudioFileSetThumbnailService.call(object.thumbnail)
        end
      end
      if solr_doc['geographic_coverage_label_tesim'] or solr_doc['chronological_coverage_tesim']
        geographic_label = solr_doc['geographic_coverage_label_tesim']
        chronological_label = solr_doc['chronological_coverage_tesim']
        solr_doc['oai_dc_coverage_tesim'] = [geographic_label, chronological_label].reject { |val| val.nil? }.flatten
      end
      if resource_type = solr_doc['resource_type_tesim']
        solr_doc['oai_dc_type_tesim'] = resource_type.map { |val| Hyrax::ResourceTypesService.label(val).gsub(' ','') }
      end
      if collections = solr_doc['member_of_collections_ssim']
        solr_doc['oai_dc_relation_tesim'] = collections.map { |val| "IsPartOf #{val}" }
      end
      solr_doc['title_sort_ssi'] = object.title.first unless object.title.empty?
      if full_text_contents = object.file_sets.select { |fs| fs.extracted_text.present? } and full_text_contents.present?
        solr_doc['full_text_tsi'] = full_text_contents.map {|fs| fs.extracted_text.content }.join("")
      end
      if object.visibility == "authenticated"
        solr_doc["discover_access_group_ssim"] = "public"
      end
      unless object.date_created.empty?
        object.date_created.each do |date|
          service = EdtfDateService.new(date)
          (solr_doc['year_sort_dtsim']||= []) << service.solr_date_range
          (solr_doc['year_sort_dtsi']||= []) << service.first_solr_date
          (solr_doc['year_range_isim']||=[]) << service.year_range
        end
        solr_doc['year_sort_dtsim'] = solr_doc['year_sort_dtsim'].flatten.uniq.sort
        solr_doc['year_sort_dtsi'] = solr_doc['year_sort_dtsim'].first
        solr_doc['year_range_isim'] = solr_doc['year_range_isim'].flatten.uniq.sort
      end
    end
  end
def generate_solr_document object . attribute_names . each do | field | if object . controlled_properties . include? ( field . to_sym ) and object [ field ] . present? to_controlled_vocab ( field ) end end super . tap do | solr_doc | if object . thumbnail and object . thumbnail . files . any? if object . thumbnail . audio? or object . thumbnail . files . first . file_name . first . include? ( ".m4a" ) solr_doc [ 'thumbnail_path_ss' ] = AudioFileSetThumbnailService . call ( object . thumbnail ) end end if solr_doc [ 'geographic_coverage_label_tesim' ] or solr_doc [ 'chronological_coverage_tesim' ] geographic_label = solr_doc [ 'geographic_coverage_label_tesim' ] chronological_label = solr_doc [ 'chronological_coverage_tesim' ] solr_doc [ 'oai_dc_coverage_tesim' ] = [ geographic_label , chronological_label ] . reject { | val | val . nil? } . flatten end if resource_type = solr_doc [ 'resource_type_tesim' ] solr_doc [ 'oai_dc_type_tesim' ] = resource_type . map { | val | Hyrax :: ResourceTypesService . label ( val ) . gsub ( ' ' , '' ) } end if collections = solr_doc [ 'member_of_collections_ssim' ] solr_doc [ 'oai_dc_relation_tesim' ] = collections . map { | val | "IsPartOf #{val}" } end solr_doc [ 'title_sort_ssi' ] = object . title . first unless object . title . empty? if full_text_contents = object . file_sets . select { | fs | fs . extracted_text . present? } and full_text_contents . present? solr_doc [ 'full_text_tsi' ] = full_text_contents . map { | fs | fs . extracted_text . content } . join ( "" ) end if object . visibility == "authenticated" solr_doc [ "discover_access_group_ssim" ] = "public" end unless object . date_created . empty? object . date_created . each do | date | service = EdtfDateService . new ( date ) ( solr_doc [ 'year_sort_dtsim' ] ||= [ ] ) << service . solr_date_range ( solr_doc [ 'year_sort_dtsi' ] ||= [ ] ) << service . first_solr_date ( solr_doc [ 'year_range_isim' ] ||= [ ] ) << service . year_range end solr_doc [ 'year_sort_dtsim' ] = solr_doc [ 'year_sort_dtsim' ] . flatten . uniq . sort solr_doc [ 'year_sort_dtsi' ] = solr_doc [ 'year_sort_dtsim' ] . first solr_doc [ 'year_range_isim' ] = solr_doc [ 'year_range_isim' ] . flatten . uniq . sort end end end
Uncomment this block if you want to add custom indexing behavior:
Uncomment this block if you want to add custom indexing behavior :
# Convert ActiveTriples::Resource to Hyrax::ControlledVocabulary::[field name] # This is needed for Hyrax::DeepIndexingService # Index OAI-PMH fields # dc:coverage = geographic coverage + chronological coverage # dc:resource_type = human readable label for resource type (e.g. StillImage) # dc:relation = title of parent collection if one exists # Index file sets' extracted text for display in search results # Allow public users to discover items with institution visibility