Skip to content

New SolrJ CollectionScopedSolrClient#4418

Merged
dsmiley merged 3 commits into
apache:mainfrom
dsmiley:CollectionScopedSolrClient
May 17, 2026
Merged

New SolrJ CollectionScopedSolrClient#4418
dsmiley merged 3 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.

@dsmiley
Copy link
Copy Markdown
Contributor Author

dsmiley commented May 14, 2026

gonna merge this little thing this weekend

@dsmiley dsmiley merged commit 0c8dcb8 into apache:main May 17, 2026
5 of 6 checks passed
@dsmiley dsmiley deleted the CollectionScopedSolrClient branch May 17, 2026 15:27
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