Skip to content

Construct searches using the search builder directly from the controller.#3855

Open
cbeer wants to merge 5 commits into
mainfrom
ctlr-sb
Open

Construct searches using the search builder directly from the controller.#3855
cbeer wants to merge 5 commits into
mainfrom
ctlr-sb

Conversation

@cbeer

@cbeer cbeer commented May 22, 2026

Copy link
Copy Markdown
Member

I'm not there's advantage to having Blacklight::SearchService construct the search builder internally (other than it probably made sense at the time, before we encapsulated the params with SearchState).

If we hoist the search builder up to the controller (via the Searchable concern), maybe there's less magic?

Bypassing SearchService#facet_field_response and #facet_suggest_response are potentially backwards-incompatible, but I couldn't find any indication that it's a method people are actually overriding downstream.

Includes #3856, #3843, and #3854

@cbeer cbeer force-pushed the ctlr-sb branch 3 times, most recently from 46d3dfb to 0339a6e Compare May 25, 2026 16:32
@cbeer cbeer changed the title Use search_builder to construct queries from the controller. Construct searches using the search builder directly from the controller. May 25, 2026
@cbeer cbeer marked this pull request as ready for review May 25, 2026 16:37
@barmintor

Copy link
Copy Markdown
Contributor

@jrochkind observes in Slack:
"SearchBuilder has had more or less the same API for a long time, and a lot of things in local apps and dependent *-lights depend on it, so beware there are downsides to changing it in backwards incompatible ways"

ArcLight uses a mixin that does not override the initializer.

Spotlight uses two: an access control mixin that does not override the initializer, and a category browse mixin that also does not.

GeoBlacklight likewise uses a mixin without overriding the initializer.

All of these expect SearchBuilder.default_processor_chain to be an appendable list of symbols identifying methods to be added to the processing chain for params. None of them directly instantiate a SearchBuilder outside their specs, but all of them instantiate a SearchBuilder without the blacklight_config kwarg in the specs for their mixins.

@barmintor

Copy link
Copy Markdown
Contributor

ArcLight doesn't appear to interact with SearchService at all.
GeoBlacklight references SearchService in component spec.
Spotlight has a helper method that reproduces the logic from Blacklight::Searchable.search_service, but I only see references to it in Spotlight controller mixins.

@cbeer cbeer force-pushed the ctlr-sb branch 2 times, most recently from 5114646 to 9a1e1ee Compare May 27, 2026 16:06
@cbeer

cbeer commented May 27, 2026

Copy link
Copy Markdown
Member Author

@barmintor : I think you're observing that this change is backwards-compatible (and/or having done some due diligence in some complicated apps to assure that, even if it was in some way, it doesn't impact real-world use)?

@barmintor

Copy link
Copy Markdown
Contributor

@cbeer that's right - per Jonathan's concern, I think things are mostly ok, but there is a spec in GeoBlacklight that will fail and apps that use the Spotlight helper might have an issue (though I think it may be a vestigial method).


# This method may be overridden to customize search behavior.
# @return [Blacklight::Solr::Response] the solr response object
def retrieve_search_results(params: nil)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we change this kwarg to builder since we're always passing a SearchBuilder here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just matching the argument name to the repository for consistency.

builder = builder.facet_suggestion_query(params[:query_fragment])
end

@response = retrieve_search_results(params: builder)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This conflates search results (documents) from facet results. Can we keep these two concerns separated?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any value in doing that? I find the current state incredibly confusing and it's not clear to me what behavior the seam is intending to provide that isn't better suited for the search builder.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that it is confusing, and having one method handle the one case makes it less so.

@cbeer cbeer force-pushed the ctlr-sb branch 2 times, most recently from 0d5039d to d113f8b Compare June 2, 2026 17:14
@cbeer cbeer force-pushed the ctlr-sb branch 2 times, most recently from 0d13b0d to d113f8b Compare June 17, 2026 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants