On 6/20/2014 5:16 AM, Frederic Esnault wrote: > I know how to send solrconfig.xml and schema.xml files to SolR using curl > commands. > But my problem is that i want to send them with java, and i can't find a > way to do so. > I used HttpComponentsand got http headers before the file begins, which SAX > parser does not like at all. > > What is the best way to send this files from a java program ?
Chances are good that you can duplicate your curl requests with HttpSolrServer and SolrQuery, part of solrj, which is in the Solr download under the dist directory. If you are running SolrCloud, then the configs in Zookeeper are directly accessible with Java code. You should take a look at the source code, in ZkController#uploadConfigDir, to see how the uploadToZK methods work. You should be able to use the SolrZkClient#makePath method, just like uploadToZK does. To use SolrZKClient (or the requests similar to what you do now with curl), you will need the solrj jar and it's dependencies. The recommended versions of those dependencies can be found in the download, in the dist/solrj-lib directory. To get the SolrZkClient, you would need to establish a CloudSolrServer object, then retrieve the ZkStateReader from the CloudSolrServer, and the SolrZkClient from the ZkStateReader. Thanks, Shawn