solrsolrj

How to get the Solr Master Slave replication status using Solrj


I am trying to retrieve the Solr Master Slave replication status using SolrJ. I have not been able to find how to get this using the Core Admin calls or set the request handler to the Replication handler.

Or perhaps I could call this HTTP API call using SolrJ

http://host:port/solr/core_name/replication?command=indexversion

But how to that is something that escapes me currently.

Looking for pointers in this direction.


Solution

  • Just in case this helps someone, what I did to get the data I needed was

        SolrClient solrServer = new HttpSolrClient.Builder("http://localhost:8983/solr/" + coreName).build();
        SolrQuery query = new SolrQuery();
        query.setRequestHandler("/replication");
        query.set("command", "indexversion");
        query.set("wt", "json");
        query.set("indent", "true");
    
        //fire the solr query
        QueryResponse response = solrServer.query(query);
    
        //get the indexversion value from response
        String indexVersion = 
        response.getResponse().get("indexversion").toString();