Grouped result aren't shown or Paging is wrong
I can't get a grouping / field collapsing setup in blacklight, which works correctly.
Either I use (additionally to base setup of the grouping: :group => true, :'group.field' => 'source_id', :'group.ngroups' => true):
-
:group.format=simple: results are displayed, but the paging is wrong. The total amount (numFound) is used for creating the paging, notngroups - if not: no results will be shown, but the paging is correct
I'm not shure if this is a bug, but it seems, that something is going wrong in the app/helpers/blacklight/blacklight_helper_behavior.rb whilst defining if the response is grouped or whilst using the ngroup instead of numFound (app/helpers/blacklight/catalog_helper_behavior.rb). I tried to figure it out on myself, but I'm quite new in blacklight, rails ...
I'm using Blacklight 5.2 with blacklight-jetty-4.6.0/.
I believe we need to change https://github.com/projectblacklight/blacklight/blob/master/lib/blacklight/solr_response/group.rb#L18-L20 to be
def total
doclist[:ngroups].to_s.to_i
end
as is the case in the code that was part of the inspiration for the integration into Blacklight ( https://github.com/sul-dlss/frda/blob/master/lib/frda/grouped_solr_response.rb#L31 ). There may be some other considerations around paginating grouped responses that we'll want to take a look at to make sure it works the same as the existing flat document list pagination.
I don't think this is the solution. 'ngroups' returns the number of groups, not the total number of results. There is a field called 'matches' which should be the correct number of results equal to the sum of the number in each category (group). If you are looking for matches in each group, then it would 'numFound'.
Moving to 7.x, cf #1249