You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Markus Schuch <ma...@deutschebahn.com> on 2019/03/18 20:04:02 UTC

SolrJ - CoreAdminRequest / PingRequest and HttpSolrClient baseUrl

Hi folks,

i have a question about how to perform a connection check with SolrJ in a generic way.

I found PingRequest and CoreAdminRequest in SolrJ.
Neither of both work in both scenarios when a SolrClient is created by HttpSolrClient.Builder with AND without having the baseUrl containing the path to a particular core:


  *   CoreAdminRequest - is only working when no particular core is given
  *   PingRequest - is only working when a particular core is given

Here is a sample test case demonstrating both scenarios: https://gist.github.com/schuch/9d86383cb36244c1b6ec0360ebf739a5

Is this behavior intended or might it be a bug?
Is there a better way to do a connection check?

My use case:
I look for an improvement for the spring boot solr health indicator: https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/solr/SolrHealthIndicator.java

It currently uses the CoreAdminRequest which fails when the SolrClient points to a particular core.

Many thanks in advance,
Markus

________________________________

Pflichtangaben anzeigen<http://www.deutschebahn.com/pflichtangaben/20190306>

N?here Informationen zur Datenverarbeitung im DB-Konzern finden Sie hier: http://www.deutschebahn.com/de/konzern/datenschutz

Re: SolrJ - CoreAdminRequest / PingRequest and HttpSolrClient baseUrl

Posted by Shawn Heisey <ap...@elyograg.org>.
On 3/18/2019 2:04 PM, Markus Schuch wrote:
>    *   CoreAdminRequest - is only working when no particular core is given
>    *   PingRequest - is only working when a particular core is given

That sounds like what I would expect to happen.

Using HTTP (not SolrJ), the CoreAdmin API is accessed through a URL that 
does NOT contain a core name in the URL path.  If you initialize your 
HttpSolrClient using a URL that contains the core name, you won't be 
able to use that client for CoreAdmin requests -- because CoreAdmin 
requests do not use that kind of URL.

Similarly, the Ping handler is accessed through a URL that DOES contain 
the core name in the URL path.  You can use a client initialized without 
a core name by providing the core name when you execute the request. 
See the following code:

     @Test
     public void testPingWithoutCore() throws IOException, 
SolrServerException {
     	String coreToTest = "techproducts";
         HttpSolrClient client = new 
HttpSolrClient.Builder().withBaseSolrUrl("http://localhost:8983/solr").build();
         SolrPing ping = new SolrPing();
         SolrPingResponse response = ping.process(client, coreToTest);
         assertEquals(0, response.getStatus());
     }


Re: SolrJ - CoreAdminRequest / PingRequest and HttpSolrClient baseUrl

Posted by Jörn Franke <jo...@gmail.com>.
Depends what you want to achieve. You can also have two different beans with two different clients and one accesses a core and another accesses without.

You may also want depending on your use case get all cores and ping each core individually to check if they are reachable.

> Am 18.03.2019 um 21:04 schrieb Markus Schuch <ma...@deutschebahn.com>:
> 
> Hi folks,
> 
> i have a question about how to perform a connection check with SolrJ in a generic way.
> 
> I found PingRequest and CoreAdminRequest in SolrJ.
> Neither of both work in both scenarios when a SolrClient is created by HttpSolrClient.Builder with AND without having the baseUrl containing the path to a particular core:
> 
> 
>  *   CoreAdminRequest - is only working when no particular core is given
>  *   PingRequest - is only working when a particular core is given
> 
> Here is a sample test case demonstrating both scenarios: https://gist.github.com/schuch/9d86383cb36244c1b6ec0360ebf739a5
> 
> Is this behavior intended or might it be a bug?
> Is there a better way to do a connection check?
> 
> My use case:
> I look for an improvement for the spring boot solr health indicator: https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/solr/SolrHealthIndicator.java
> 
> It currently uses the CoreAdminRequest which fails when the SolrClient points to a particular core.
> 
> Many thanks in advance,
> Markus
> 
> ________________________________
> 
> Pflichtangaben anzeigen<http://www.deutschebahn.com/pflichtangaben/20190306>
> 
> N?here Informationen zur Datenverarbeitung im DB-Konzern finden Sie hier: http://www.deutschebahn.com/de/konzern/datenschutz