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
SOLR-17066: Add 'defaultCollection' to SolrClients #2066
SOLR-17066: Add 'defaultCollection' to SolrClients #2066
Conversation
This commit adds a setter ('withDefaultCollection(String)') to all SolrClient builders, and propagates the field down to each client implementation. All SolrClient implementations now have a getter to fetch this property ('getDefaultCollection'). NOTE: This commit doesn't actually have the clients use the new field anywhere. That will happen in a separate commit, in hopes that splitting up those two pieces across commit boundaries will make backporting easier when the time comes.
I've been thinking a bit about how to get this change in. I imagine core-based URLs are pretty common in Solr - common enough that it'd be tough to switch them all over in this PR (or in any single PR). So my thought was that this PR could stay pretty narrowly targeted on introducing the SolrClient and Builder plumbing, and that subsequent SOLR-17066 PRs would handle switching over various SolrClient instantiations to use this new plumbing. Lmk if anyone can think of a better way to break this work up! |
Makes sense! |
This commit adds a setter ('withDefaultCollection(String)') to all SolrClient builders, and propagates the field down to each client implementation. All SolrClient implementations now have a getter to fetch this property ('getDefaultCollection'). This will help users replace the anti-pattern of baking the collection/ core name into their client's base URL to achieve a sort of "poor man's" default.
https://issues.apache.org/jira/browse/SOLR-17066
Description
CloudSolrClient has long had a 'defaultCollection' property. This property acts as a default, saving users who only interact with a single core from still needing to specify its name repetitiously. Unfortunately, this nicety is missing from many other client implementations.
Solution
This PR adds
defaultCollection
as a protected field on the abstractSolrClient
class. It adds the required plumbing in "Builder" classes and client constructors to allow users to set the value. And of course it modifies therequest()
implementation for each client to use the default when an explicit collection has not been specified.Tests
Tests are still needed and will be added prior to taking this out of 'draft' mode.
Checklist
Please review the following and check all that apply:
main
branch../gradlew check
.