2017-03-24 69 views
0

如何使用Solrj使用以下API查詢Solr的:Solrj查詢Solr的:dataimport.properties文件

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

上述API使得dataimport.properties的內容文件。

{ 
    "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,我的Solr配置爲雲模式。

回答

0

鑑於您的Solr正在Cloud模式下運行,文件/configs/my-search/dataimport.properties進入Zookeeper。

SolrJ沒有本地API來輕鬆從Zookeeper讀取。

要讀入到動物園管理員,我建議用使用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); 
}