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

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

Closed
seanaery opened this issue Nov 8, 2024 · 2 comments · Fixed by #273
Closed
Assignees

Comments

@seanaery
Copy link
Collaborator

seanaery commented Nov 8, 2024

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": {...}
}
@jrochkind
Copy link
Member

I'm personally unlikely to have time to try to implement this (and have never used group search results), but would find time to review PRs.

Presumably it just requires changing the query that's sent to Solr and/or how the results are parsed? To do what Blacklight itself is doing? It could be a fairly small tweak.

I feel like this plugin tries to use your configured CatalogController already to get results though, in a way that it should already incorporate any logic Blacklight original has for delaing with grouped results in facets... ah but maybe not when it comes to facets, since we have to do special stuff there. Anyway, I think the chances are good of it being a small code change, the hard part is figuring out that small code change. first place to look is what Blacklight itself is doing for grouped results in facets .

@jrochkind
Copy link
Member

Oh ha, after writing all that I see you already have a PR, sweet!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants