How can I get path to an instanceDir with solrj?
I know the path to SOLR_HOME and I know the actual name of the collection but the actual instanceDir of the collection might be different.
e.g. the collection with the name "foo" maybe in the directory solr_home/foobar_1/
or in solr_home/foobar_0/
So how can I find out if the directory of this collection is called foobar_1 or foobar_0 with solrj?
Your question is how to get the InstanceDir of a solr core with solrj.
The corresponding URL to get this information is:
This code use solrj to get the information:
SolrClient client = new HttpSolrClient("http://localhost:8983/solr/");
String core = "myCore";
// Core Admin API
CoreAdminRequest status = new CoreAdminRequest();
status.setAction(CoreAdminAction.STATUS);
status.setCoreName(core);
CoreAdminResponse rspStatus = status.process(client);
String instanceDirCore = (String) rspStatus.getCoreStatus().findRecursive(core, "instanceDir");
System.out.println(instanceDirCore);
// Core Overview
GenericSolrRequest system = new GenericSolrRequest(METHOD.GET, "/admin/system", new ModifiableSolrParams());
SimpleSolrResponse rsp = system.process(client, core);
String instanceDir = (String) rsp.getResponse().findRecursive("core", "directory", "instance");
System.out.println(instanceDir);
assert instanceDir.equals(instanceDirCore);