@@ -487,13 +487,14 @@ def get_solr_response_for_field_values(field, values, extra_solr_params = {})
487487 # method facet_list_limit, otherwise 20.
488488 def solr_facet_params ( facet_field , user_params = params || { } , extra_controller_params = { } )
489489 input = user_params . deep_merge ( extra_controller_params )
490+ facet_config = blacklight_config . facet_fields [ facet_field ]
490491
491492 # First start with a standard solr search params calculations,
492493 # for any search context in our request params.
493494 solr_params = solr_search_params ( user_params ) . merge ( extra_controller_params )
494495
495496 # Now override with our specific things for fetching facet values
496- solr_params [ :"facet.field" ] = facet_field
497+ solr_params [ :"facet.field" ] = with_ex_local_param ( ( facet_config . ex if facet_config . respond_to? ( :ex ) ) , facet_field )
497498
498499
499500 limit =
@@ -515,26 +516,31 @@ def solr_facet_params(facet_field, user_params=params || {}, extra_controller_pa
515516 return solr_params
516517 end
517518
519+ ##
520+ # Get the solr response when retrieving only a single facet field
521+ def get_facet_field_response ( facet_field , user_params = params || { } , extra_controller_params = { } )
522+ solr_params = solr_facet_params ( facet_field , user_params , extra_controller_params )
523+ # Make the solr call
524+ find ( blacklight_config . qt , solr_params )
525+ end
526+
518527 # a solr query method
519528 # used to paginate through a single facet field's values
520529 # /catalog/facet/language_facet
521530 def get_facet_pagination ( facet_field , user_params = params || { } , extra_controller_params = { } )
522-
523- solr_params = solr_facet_params ( facet_field , user_params , extra_controller_params )
524-
525531 # Make the solr call
526- response = find ( blacklight_config . qt , solr_params )
532+ response = get_facet_field_response ( facet_field , user_params , extra_controller_params )
533+
534+ limit = response . params [ :"f.#{ facet_field } .facet.limit" ] . to_s . to_i - 1
527535
528- limit = solr_params [ :"f.#{ facet_field } .facet.limit" ] -1
529-
530536 # Actually create the paginator!
531537 # NOTE: The sniffing of the proper sort from the solr response is not
532538 # currently tested for, tricky to figure out how to test, since the
533539 # default setup we test against doesn't use this feature.
534540 return Blacklight ::Solr ::FacetPaginator . new ( response . facets . first . items ,
535- :offset => solr_params [ :"f.#{ facet_field } .facet.offset" ] ,
541+ :offset => response . params [ :"f.#{ facet_field } .facet.offset" ] ,
536542 :limit => limit ,
537- :sort => response [ "responseHeader" ] [ " params" ] [ :"f.#{ facet_field } .facet.sort" ] || response [ "responseHeader" ] [ " params" ] [ "facet.sort" ]
543+ :sort => response . params [ :"f.#{ facet_field } .facet.sort" ] || response . params [ "facet.sort" ]
538544 )
539545 end
540546
@@ -612,23 +618,23 @@ def get_opensearch_response(field=nil, extra_controller_params={})
612618 # a facet paginator with the right limit.
613619 def facet_limit_for ( facet_field )
614620 facet = blacklight_config . facet_fields [ facet_field ]
615- return nil if facet . blank?
616-
617- limit = facet . limit
618-
619- if ( limit == true && @response &&
620- @response [ "responseHeader" ] &&
621- @response [ "responseHeader" ] [ "params" ] )
622- limit =
623- @response [ "responseHeader" ] [ "params" ] [ "f.#{ facet_field } .facet.limit" ] ||
624- @response [ "responseHeader" ] [ "params" ] [ "facet.limit" ]
625- limit = ( limit . to_i ( ) -1 ) if limit
626- limit = nil if limit == -2 # -1-1==-2, unlimited.
627- elsif limit == true
628- limit = nil
629- end
630621
631- return limit
622+ return if facet . blank?
623+
624+ if facet . limit and @response
625+ limit = @response . params [ "f.#{ facet_field } .facet.limit" ] ||
626+ @response . params [ "facet.limit" ]
627+
628+ if limit . blank? # we didn't get or a set a limit, so infer one.
629+ facet . limit if facet . limit != true
630+ elsif limit == -1 # limit -1 is solr-speak for unlimited
631+ nil
632+ else
633+ limit . to_i - 1 # we added 1 to find out if we needed to paginate
634+ end
635+ elsif ( facet . limit and facet . limit != true )
636+ facet . limit
637+ end
632638 end
633639
634640 ##
0 commit comments