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.5.0 app/search_builders/curation_concerns/collection_search_builder.rb
curation_concerns-1.4.0 app/search_builders/curation_concerns/collection_search_builder.rb
curation_concerns-1.3.3 app/search_builders/curation_concerns/collection_search_builder.rb
curation_concerns-1.3.2 app/search_builders/curation_concerns/collection_search_builder.rb
curation_concerns-1.3.1 app/search_builders/curation_concerns/collection_search_builder.rb
curation_concerns-1.3.0 app/search_builders/curation_concerns/collection_search_builder.rb
curation_concerns-1.2.0 app/search_builders/curation_concerns/collection_search_builder.rb
curation_concerns-1.1.2 app/search_builders/curation_concerns/collection_search_builder.rb
curation_concerns-1.1.1 app/search_builders/curation_concerns/collection_search_builder.rb
curation_concerns-1.1.0 app/search_builders/curation_concerns/collection_search_builder.rb
curation_concerns-1.0.0 app/search_builders/curation_concerns/collection_search_builder.rb
curation_concerns-1.0.0.beta10 app/search_builders/curation_concerns/collection_search_builder.rb
curation_concerns-1.0.0.beta9 app/search_builders/curation_concerns/collection_search_builder.rb
curation_concerns-1.0.0.beta8 app/search_builders/curation_concerns/collection_search_builder.rb
curation_concerns-1.0.0.beta7 app/search_builders/curation_concerns/collection_search_builder.rb
curation_concerns-1.0.0.beta6 app/search_builders/curation_concerns/collection_search_builder.rb
curation_concerns-1.0.0.beta5 app/search_builders/curation_concerns/collection_search_builder.rb
curation_concerns-1.0.0.beta4 app/search_builders/curation_concerns/collection_search_builder.rb
curation_concerns-1.0.0.beta3 app/search_builders/curation_concerns/collection_search_builder.rb
curation_concerns-1.0.0.beta2 app/search_builders/curation_concerns/collection_search_builder.rb