Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #765 - single => true' on facet now works on "more" screen #767

Closed
wants to merge 6 commits into from
Closed
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 29 additions & 21 deletions lib/blacklight/solr_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,28 @@ def add_facetting_to_solr(solr_parameters, user_params)

blacklight_config.facet_fields.each do |field_name, facet|

if blacklight_config.add_facet_fields_to_solr_request
# Adds params required for advanced facets
handle_advanced_facets(solr_parameters, facet)

# Support facet paging and 'more'
# links, by sending a facet.limit one more than what we
# want to page at, according to configured facet limits.
solr_parameters[:"f.#{facet.field}.facet.limit"] = (facet_limit_for(field_name) + 1) if facet_limit_for(field_name)
end
end

def with_ex_local_param(ex, value)
if ex
"{!ex=#{ex}}#{value}"
else
value
end
end

##
# Advanced facets (pivot facet, query facet, facet with ex param...) need special params attached.
def handle_advanced_facets(solr_parameters, facet)
if blacklight_config.add_facet_fields_to_solr_request
case
when facet.pivot
solr_parameters.append_facet_pivot with_ex_local_param(facet.ex, facet.pivot.join(","))
Expand All @@ -322,30 +343,15 @@ def add_facetting_to_solr(solr_parameters, user_params)
if facet.sort
solr_parameters[:"f.#{facet.field}.facet.sort"] = facet.sort
end

if facet.solr_params
if facet.solr_params
facet.solr_params.each do |k, v|
solr_parameters[:"f.#{facet.field}.#{k}"] = v
end
end

end

# Support facet paging and 'more'
# links, by sending a facet.limit one more than what we
# want to page at, according to configured facet limits.
solr_parameters[:"f.#{facet.field}.facet.limit"] = (facet_limit_for(field_name) + 1) if facet_limit_for(field_name)
end
end

def with_ex_local_param(ex, value)
if ex
"{!ex=#{ex}}#{value}"
else
value
end
end

end

def add_solr_fields_to_query solr_parameters, user_parameters
return unless blacklight_config.add_field_configuration_to_solr_request

Expand Down Expand Up @@ -493,8 +499,10 @@ def solr_facet_params(facet_field, user_params=params || {}, extra_controller_pa
solr_params = solr_search_params(user_params).merge(extra_controller_params)

# Now override with our specific things for fetching facet values
solr_params[:"facet.field"] = facet_field
solr_params[:"facet.field"] = [facet_field]

# After overriding the facet values we need to handle advanced facets like we do in :add_facetting_to_solr
handle_advanced_facets(solr_params, blacklight_config.facet_fields[facet_field])

limit =
if respond_to?(:facet_list_limit)
Expand Down