Class: Hyrax::CollectionSearchBuilder

Inherits:
SearchBuilder
  • Object
show all
Includes:
FilterByType
Defined in:
app/search_builders/hyrax/collection_search_builder.rb

Overview

Note:

the default_processor_chain defined by Blacklight::Solr::SearchBuilderBehavior provides many possible points of override

Our parent class is the generated SearchBuilder descending from Blacklight::SearchBuilder It includes Blacklight::Solr::SearchBuilderBehavior, Hydra::AccessControlsEnforcement, Hyrax::SearchFilters Allows :deposit as a valid type

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from FilterByType

#filter_models

Instance Attribute Details

#accessObject (readonly)

Returns the value of attribute access.



14
15
16
# File 'app/search_builders/hyrax/collection_search_builder.rb', line 14

def access
  @access
end

Instance Method Details

#add_sorting_to_solr(solr_parameters) ⇒ Object

Sort results by title if no query was supplied. This overrides the default ‘relevance’ sort.



38
39
40
41
42
# File 'app/search_builders/hyrax/collection_search_builder.rb', line 38

def add_sorting_to_solr(solr_parameters)
  return if solr_parameters[:q]
  solr_parameters[:sort] ||= sort
  solr_parameters[:sort] ||= "#{sort_field} asc"
end

#discovery_permissionsObject

Overrides Hydra::AccessControlsEnforcement



17
18
19
# File 'app/search_builders/hyrax/collection_search_builder.rb', line 17

def discovery_permissions
  @discovery_permissions = extract_discovery_permissions(@access)
end

#gated_discovery_filters(permission_types = discovery_permissions, ability = current_ability) ⇒ Array<String>

If :deposit access is requested, check to see which collections the user has deposit or manage access to.

Returns:

  • (Array<String>)

    a list of filters to apply to the solr query



47
48
49
50
# File 'app/search_builders/hyrax/collection_search_builder.rb', line 47

def gated_discovery_filters(permission_types = discovery_permissions, ability = current_ability)
  return super unless permission_types.include?("deposit")
  ["{!terms f=id}#{collection_ids_for_deposit.join(',')}"]
end

#modelsObject

This overrides the models in FilterByType



27
28
29
# File 'app/search_builders/hyrax/collection_search_builder.rb', line 27

def models
  collection_classes
end

#sort_fieldString

Returns Solr field name indicating default sort order.

Returns:

  • (String)

    Solr field name indicating default sort order



22
23
24
# File 'app/search_builders/hyrax/collection_search_builder.rb', line 22

def sort_field
  "title_si"
end

#with_access(access) ⇒ Object



31
32
33
34
# File 'app/search_builders/hyrax/collection_search_builder.rb', line 31

def with_access(access)
  @access = access
  super(access)
end