torvalds-dev / solr

Apache Solr open-source search software
https://solr.apache.org/
Apache License 2.0
0 stars 0 forks source link

CloudSolrClient.Builder should accept a zk host #21

Open 0xDTE opened 1 year ago

0xDTE commented 1 year ago

Today we need to create an empty builder and then wither pass zkHost or withSolrUrl

SolrClient solrClient = new CloudSolrClient.Builder().withZkHost("localhost:9983").build(); solrClient.request(updateRequest, "gettingstarted"); What if we have two constructors , one that accepts a zkHost and one that accepts a SolrUrl .

The advantages that I can think of are:

It will be obvious to users that we support two mechanisms of creating a CloudSolrClient . The SolrUrl option is cool and applications don't need to know about ZooKeeper and new users will learn about this . Maybe our example's on the ref guide should use this? Today people can set both zkHost and solrUrl but CloudSolrClient can only utilize one of them HttpClient's Builder accepts the host

HttpSolrClient client = new HttpSolrClient.Builder("http://localhost:8983/solr").build(); client.request(updateRequest, "techproducts");

torvalds-dev commented 1 year ago

torvalds.dev is analyzing the ticket

torvalds-dev commented 1 year ago

torvalds.dev is analyzing the ticket

torvalds-dev commented 1 year ago

The issue at hand is related to the CloudSolrClient.Builder class in Apache Solr. Currently, the builder class requires the user to create an empty builder and then pass either a zkHost (ZooKeeper host) or withSolrUrl. The user is suggesting that two constructors be created, one that accepts a zkHost and one that accepts a SolrUrl.

The advantages of this approach, as stated by the user, are:

  1. It will be clear to users that two mechanisms of creating a CloudSolrClient are supported.
  2. The SolrUrl option is user-friendly and applications don't need to know about ZooKeeper.
  3. Currently, users can set both zkHost and solrUrl but CloudSolrClient can only utilize one of them.

The user also points out that HttpClient's Builder accepts the host, which is a feature they would like to see in CloudSolrClient.Builder.

The relevant files to this issue are:

  1. solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientBuilderTest.java
  2. solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientBuilderTest.java

These files contain tests for the CloudSolrClient.Builder and CloudHttp2SolrClient.Builder classes respectively.

Based on the issue, the following actions should be taken:

  1. Modify the CloudSolrClient.Builder and CloudHttp2SolrClient.Builder classes to include two constructors, one that accepts a zkHost and one that accepts a SolrUrl.
  2. Update the documentation and examples to reflect these changes and make it clear to users that two mechanisms of creating a CloudSolrClient are supported.
  3. Update the tests in CloudSolrClientBuilderTest.java and CloudHttp2SolrClientBuilderTest.java to test the new constructors.
  4. Ensure that if both zkHost and solrUrl are set, an appropriate error is thrown or one of them is prioritized.