Sha256: a5fec79737e8edf3997317d299caf7839015d7ea0fb5ff245a268256702bbd50

Contents?: true

Size: 954 Bytes

Versions: 4

Compression:

Stored size: 954 Bytes

Contents

# frozen_string_literal: true
module Hyrax
  # Finds the child objects contained within a collection
  class MemberWithFilesSearchBuilder < ::SearchBuilder
    class_attribute :from_field
    self.from_field = 'child_object_ids_ssim'
    self.default_processor_chain += [:include_collection_ids, :include_contained_files]

    # This is like include_collection_ids, but it also joins the files.
    def include_contained_files(solr_parameters)
      solr_parameters[:fq] ||= []
      solr_parameters[:fq] << "{!join from=member_ids_ssim to=id}{!join from=child_object_ids_ssim to=id}id:#{collection_id}"
    end

    # include filters into the query to only include the collection memebers
    def include_collection_ids(solr_parameters)
      solr_parameters[:fq] ||= []
      solr_parameters[:fq] << "{!join from=#{from_field} to=id}id:#{collection_id}"
    end

    private

    def collection_id
      blacklight_params.fetch('id')
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hyrax-5.0.2 app/search_builders/hyrax/member_with_files_search_builder.rb
hyrax-5.0.1 app/search_builders/hyrax/member_with_files_search_builder.rb
hyrax-5.0.0 app/search_builders/hyrax/member_with_files_search_builder.rb
hyrax-5.0.0.rc3 app/search_builders/hyrax/member_with_files_search_builder.rb