SolrJ offers a number of different Types of SolrClients. They are listed here: https://solr.apache.org/guide/solr/latest/deployment-guide/solrj.html#types-of-solrclients
Now if you just simply want to query your Solr instance over HTTP you would probably choose either HttpSolrClient
or Http2SolrClient
. Http2SolrClient
sounds newer, so you probably would like to choose this type of client, as it for example supports HTTP/2. But the reference guide tells us that it is an experimental class and its API might be changed or removed in any minor release. That does not sound very promising. So of course you fallow this advice and then go on to use the old HttpSolrClient
Class. But when you do, your IDE will give you a deprecation warning. What does it tell you to use instead? Of course: Http2SolrClient
.
I am deeply confused. That can’t be, my IDE must have made a mistake. so I try to find the real documentation for this online, and indeed, the class is deprecated for real, and they really do want you to use the Http2SolrClient
Client instead. https://solr.apache.org/docs/9_4_0/solrj/org/apache/solr/client/solrj/impl/HttpSolrClient.html I thought I cant be the only one, but as it seems no one prior to me asked a similar question on Stack Overflow, or a was just not able to find it.
So who is to believe in this case. Is it the javadoc written by the developers of solrJ or is it the reference guide? Maybe a statement or an explanation from the solr team would be great. https://issues.apache.org/jira/browse/SOLR-15223 (commit: https://github.com/apache/solr/commit/77921bab52f5a3ec11626759ab72e0a6f0b62092) In Jira they explained why they deprecated one class, but they don’t explain why there are now two different versions of realities in the solr universe. I am tempted to believe the developers on this one, but why did no one bother to change the reference guide?
As every sane being I expect the reference guide and the javadoc to tell the same story. As of today, they not only state two different things, the stand completely contrary to each other.
I can see how it is frustrating to have to choose between a deprecated and an experimental client. Fact is that in 9.x you still have a choice, and the deprecated one may in certain corner cases still be preferable. However, the Http2SolrClient has been around long enough that we just proposed making it non experimental, so do not be afraid of giving it a try. When 9.6 comes out you'll have a third choice, the HttpJdkSolrClient
, an option using JDK11 HTTP client, with no need for either apache-http or jetty-http dependencies.
When upgrading to Solr 10 (expected by end of 2024), the HttpSolrClient will be gone.