Skip to content

Grouped search results views break the range facet display (ArcLight incompatibility) #272

@seanaery

Description

@seanaery

Overview

When search results are grouped (a feature essential to ArcLight), the range limit facet will show zero results for the selected range, and fail to render a histogram.
Screenshot 2024-11-07 at 4 24 58 PM

This is a long-standing issue that pre-dates v9.x of blacklight_range_limit; it does not appear that the plugin has ever accounted for grouped search results.

Steps to Reproduce

This would be true of any Blacklight app that uses grouped search results. ArcLight certainly does; TBD which other BL-based applications are impacted.

  • In a new ArcLight app w/blacklight_range_limit added, perform a blank search
  • Enter any date range in the facet; click Apply button
  • Plugin works correctly here (shows correct hits for selected range and displays histogram)
  • Toggle results to Grouped by collection
  • Plugin will show 0 hits for the selected range (and fail to show the histogram)

Why This Matters

The majority of current ArcLight implementations have added the blacklight_range_limit gem and have had to make various local fixes to get it to work correctly. Grouping by collection is essential and the community even supports making that the default view of search results (see projectblacklight/arclight#1488). It would be quite helpful to the community if this plugin would just work out-of-the-box for ArcLight without requiring local modifications.

Some Technical Details

The BlacklightRangeLimit::FacetFieldPresenter currently expects the Solr response for search results to be a Blacklight::Solr::Response and for the total hit count to be in response.total, aka response['numFound'] (see code).

E.g., for a query yielding 510 docs:

{
  "responseHeader": {...},
  "response": {
    "numFound": 510,
    "start": 0,
    "numFoundExact": true,
    "docs": [...]
  },
  "facet_counts": {...},
  "highlighting": {...},
  "stats": {...}
}

But when search results are grouped, the Solr response does not use numFound. The total doc count will instead be in ['grouped']['_root_']['matches'], where _root_ is the applied group.field, e.g. :

{
  "responseHeader": {...},
  "grouped": {
    "_root_": {
      "matches": 510,
      "ngroups": 8,
      "groups": [...]
    }
  },
  "facet_counts": {...},
  "highlighting": {...},
  "stats": {...}
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions