Skip to content

New SolrJ CollectionScopedSolrClient#4418

Open
dsmiley wants to merge 2 commits into
apache:mainfrom
dsmiley:CollectionScopedSolrClient
Open

New SolrJ CollectionScopedSolrClient#4418
dsmiley wants to merge 2 commits into
apache:mainfrom
dsmiley:CollectionScopedSolrClient

Conversation

@dsmiley
Copy link
Copy Markdown
Contributor

@dsmiley dsmiley commented May 11, 2026

This SolrClient delegates to a backing client with a specified collection. Simple attempts to refer to another collection will fail. DISCLAIMER: this isn't a security mechanism.

There are tests and places in client code I've seen that would benefit from this. For one thing, it enables taking an existing SolrClient that doesn't have a defaultCollection (e.g. JettySolrRunner.getSolrClient()) and simply wrap it. Voila. I'm working on Jetty -> Apache transition and in the process I'm moving needless client creations to use existing clients, and I want to use this. I don't want this to "sneak in" within a test-focused PR.

I'll probably add a changelog but wasn't going to add a JIRA.

This SolrClient delegates to a backing client with a specified collection.  Simple attempts to
 * refer to another collection will fail.  DISCLAIMER: this isn't a security mechanism.
@dsmiley
Copy link
Copy Markdown
Contributor Author

dsmiley commented May 11, 2026

It could use a nice toString -- I'll add one: delegate + "/" + defaultSolrCollection

@dsmiley
Copy link
Copy Markdown
Contributor Author

dsmiley commented May 11, 2026

Out of scope here... I remain troubled by the excessive overloading of methods on SolrClient that take a collection param. I'd rather see them all gone; SolrClient just talks to a node but has a method to return a CollectionOperationsClient interface implementation (a new thing). It wouldn't subclass SolrClient; it's just a bunch of methods users expect send requests that are collection-scoped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant