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

SOLR-17066: Add 'defaultCollection' to SolrClients #2066

Conversation

gerlowskija
Copy link
Contributor

@gerlowskija gerlowskija commented Nov 7, 2023

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 abstract SolrClient class. It adds the required plumbing in "Builder" classes and client constructors to allow users to set the value. And of course it modifies the request() 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:

  • I have reviewed the guidelines for How to Contribute and my code conforms to the standards described there to the best of my ability.
  • I have created a Jira issue and added the issue ID to my pull request title.
  • I have given Solr maintainers access to contribute to my PR branch. (optional but recommended)
  • I have developed this patch against the main branch.
  • I have run ./gradlew check.
  • I have added tests for my changes.
  • I have added documentation for the Reference Guide

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.
@gerlowskija
Copy link
Contributor Author

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!

@gerlowskija gerlowskija marked this pull request as ready for review December 15, 2023 15:16
@dsmiley
Copy link
Contributor

dsmiley commented Dec 15, 2023

Makes sense!

@gerlowskija gerlowskija merged commit 0b2326d into apache:main Dec 15, 2023
2 of 3 checks passed
@gerlowskija gerlowskija deleted the SOLR-17066-add-default-collection-to-all-solrj-clients branch December 15, 2023 20:33
gerlowskija added a commit that referenced this pull request Dec 18, 2023
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.
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