Sha256: 97cac36fb5cfcf96001a477e35e2a7498eb258b7ae0fa2b87bdc8a623d6cf81b

Contents?: true

Size: 1.07 KB

Versions: 37

Compression:

Stored size: 1.07 KB

Contents

module CurationConcerns
  class CollectionSearchBuilder < ::SearchBuilder
    # Defines which search_params_logic should be used when searching for Collections
    self.default_processor_chain = [:default_solr_parameters, :add_query_to_solr,
                                    :add_access_controls_to_solr_params, :add_collection_filter, :some_rows, :sort_by_title]

    def some_rows(solr_parameters)
      solr_parameters[:rows] = '100'
    end

    def add_collection_filter(solr_parameters)
      solr_parameters[:fq] ||= []
      solr_parameters[:fq] << ActiveFedora::SolrQueryBuilder.construct_query_for_rel(has_model: ::Collection.to_class_uri)
    end

    # Sort results by title if no query was supplied.
    # This overrides the default 'relevance' sort.
    def sort_by_title(solr_parameters)
      return if solr_parameters[:q]
      solr_parameters[:sort] ||= "#{sort_field} asc"
    end

    attr_writer :discovery_perms

    def discovery_permissions
      @discovery_perms || super
    end

    def sort_field
      Solrizer.solr_name('title', :sortable)
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
curation_concerns-1.0.0.beta1 app/search_builders/curation_concerns/collection_search_builder.rb
curation_concerns-0.14.0 app/search_builders/curation_concerns/collection_search_builder.rb
curation_concerns-0.14.0.pre4 app/search_builders/curation_concerns/collection_search_builder.rb
curation_concerns-0.14.0.pre3 app/search_builders/curation_concerns/collection_search_builder.rb
curation_concerns-0.14.0.pre2 app/search_builders/curation_concerns/collection_search_builder.rb
curation_concerns-0.14.0.pre1 app/search_builders/curation_concerns/collection_search_builder.rb
curation_concerns-0.13.1 app/search_builders/curation_concerns/collection_search_builder.rb
curation_concerns-0.13.0 app/search_builders/curation_concerns/collection_search_builder.rb
curation_concerns-0.12.0 app/search_builders/curation_concerns/collection_search_builder.rb
curation_concerns-0.12.0.pre9 app/search_builders/curation_concerns/collection_search_builder.rb
curation_concerns-0.12.0.pre8 app/search_builders/curation_concerns/collection_search_builder.rb
curation_concerns-0.12.0.pre7 app/search_builders/curation_concerns/collection_search_builder.rb
curation_concerns-0.12.0.pre6 app/search_builders/curation_concerns/collection_search_builder.rb
curation_concerns-0.12.0.pre5 app/search_builders/curation_concerns/collection_search_builder.rb
curation_concerns-0.12.0.pre4 app/search_builders/curation_concerns/collection_search_builder.rb
curation_concerns-0.12.0.pre3 app/search_builders/curation_concerns/collection_search_builder.rb
curation_concerns-0.12.0.pre2 app/search_builders/curation_concerns/collection_search_builder.rb