0
votes

How can I use Solrj to query Solr using the following api:

http://localhost:8983/solr/admin/zookeeper?detail=true&path=%2Fconfigs%2Fmy-search%2Fdataimport.properties

the above api gives the content of the dataimport.properties file.

{
  "znode": {
    "path": "/configs/my-search/dataimport.properties",
    "prop": {
      "version": 186,
      "aversion": 0,
      "children_count": 0,
      "ctime": "Sun Oct 16 10:24:04 UTC 2016 (1476613444895)",
      "cversion": 0,
      "czxid": 479,
      "ephemeralOwner": 0,
      "mtime": "Fri Mar 24 09:48:50 UTC 2017 (1490348930211)",
      "mzxid": 31451,
      "pzxid": 479,
      "dataLength": 111
    },
    "data": "#Fri Mar 24 09:48:50 UTC 2017\nname.last_index_time=2017-03-24 09\\:48\\:49\nlast_index_time=2017-03-24 09\\:48\\:49\n"
  },
  "tree": [
    {
      "data": {
        "title": "dataimport.properties",
        "attr": {
          "href": "admin/zookeeper?detail=true&path=%2Fconfigs%2Fmy-search%2Fdataimport.properties"
        }
      }
    }
  ]
}

btw, my Solr is configured in cloud mode.

1

1 Answers

0
votes

Given that your Solr is running in Cloud mode the file /configs/my-search/dataimport.properties is into Zookeeper.

SolrJ does not have native API to easily read from Zookeeper.

To read into the Zookeeper I suggest to use use Apache Curator Framework

String dataPath = "/configs/my-search/dataimport.properties";
String connectionString = "zookeeper-ensemble:2181";
CuratorFramework client = CuratorFrameworkFactory.newClient(connectionString, new ExponentialBackoffRetry(1000, 3));
client.start();

byte[] barray = client.getData().forPath(dataPath);

if (barray != null) {
    String data = new String(barray);
    System.out.println(data);
}