You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Erik Hatcher <er...@ehatchersolutions.com> on 2009/04/01 17:26:14 UTC

Re: getting solr home path dynamically

On Apr 1, 2009, at 10:55 AM, Radha C. wrote:
> But I am having trouble in identifying the xml location,
> I am having the input xml in $solrhome/inputdata/example.xml, Do you  
> have
> any idea about how to get solrhome
> location dynamically by using any solrj API class?

Using SolrJ remotely, you can hit the /admin/system request handler to  
get the Solr home directory.  In a URL it'd be http://localhost:8983/solr/admin/system 
.  You get this sort of thing in the response:

<?xml version="1.0" encoding="UTF-8"?>
<response>

<lst name="responseHeader">
  <int name="status">0</int>
  <int name="QTime">80</int>
</lst>
<lst name="core">
  <str name="schema">example</str>
  <str name="host">10.0.1.193</str>

  <date name="now">2009-04-01T15:24:32.428Z</date>
  <date name="start">2009-04-01T15:21:20.765Z</date>
  <lst name="directory">
   <str name="instance">/Users/erikhatcher/dev/solr/example/solr</str>
   <str name="data">/Users/erikhatcher/dev/solr/example/./solr/data</ 
str>
   <str name="index">/Users/erikhatcher/dev/solr/example/solr/data/ 
index</str>

  </lst>
</lst>
...

And you can navigate the SolrJ response to get to the directory/ 
instance value.

I question whether it's a good idea to do this from a SolrJ client  
though, as that directory is only useful on the server itself and  
client on the same machine, but not actually remotely.  But, you can  
get at it at least :)

	Erik