Sha256: 807171aafd55857d29f5d28a0a7f967872846403d4f0f48e24c9252d15d03726

Contents?: true

Size: 1.3 KB

Versions: 12

Compression:

Stored size: 1.3 KB

Contents

module Hyrax
  # Our parent class is the generated SearchBuilder descending from Blacklight::SearchBuilder
  # It includes Blacklight::Solr::SearchBuilderBehavior, Hydra::AccessControlsEnforcement, Hyrax::SearchFilters
  # @see https://github.com/projectblacklight/blacklight/blob/master/lib/blacklight/search_builder.rb Blacklight::SearchBuilder parent
  # @see https://github.com/projectblacklight/blacklight/blob/master/lib/blacklight/solr/search_builder_behavior.rb Blacklight::Solr::SearchBuilderBehavior
  # @see https://github.com/samvera/hyrax/blob/master/app/search_builders/hyrax/README.md SearchBuilders README
  # @note the default_processor_chain defined by Blacklight::Solr::SearchBuilderBehavior provides many possible points of override
  #
  class CollectionSearchBuilder < ::SearchBuilder
    include FilterByType

    # @return [String] Solr field name indicating default sort order
    def sort_field
      Solrizer.solr_name('title', :sortable)
    end

    # This overrides the models in FilterByType
    def models
      collection_classes
    end

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

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
hyrax-2.0.3 app/search_builders/hyrax/collection_search_builder.rb
hyrax-2.0.2 app/search_builders/hyrax/collection_search_builder.rb
hyrax-2.0.1 app/search_builders/hyrax/collection_search_builder.rb
hyrax-2.0.0 app/search_builders/hyrax/collection_search_builder.rb
hyrax-2.0.0.rc3 app/search_builders/hyrax/collection_search_builder.rb
hyrax-2.0.0.rc2 app/search_builders/hyrax/collection_search_builder.rb
hyrax-2.0.0.rc1 app/search_builders/hyrax/collection_search_builder.rb
hyrax-2.0.0.beta5 app/search_builders/hyrax/collection_search_builder.rb
hyrax-2.0.0.beta4 app/search_builders/hyrax/collection_search_builder.rb
hyrax-2.0.0.beta3 app/search_builders/hyrax/collection_search_builder.rb
hyrax-2.0.0.beta2 app/search_builders/hyrax/collection_search_builder.rb
hyrax-2.0.0.beta1 app/search_builders/hyrax/collection_search_builder.rb