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 "T. Kuro Kurosaka" <ku...@basistech.com> on 2012/11/27 23:20:46 UTC

predefined variables usable in schema.xml ?

Is there a pre-defined variable that can be used in schema.xml to point 
to the solr core directory, or the conf subdirectory?
I thought ${solr.home} or perhaps ${solr.solr.home} might work but they 
didn't (unless -Dsolr.home=/my/solr/home is supplied, that is).
The default solrconfig.xml seems to suggest ${solr.data.dir} can be used.
So I am hoping there is another pre-defined variable like this that 
points to the solr core directory.

Use case, in case you wonder:
We have our custom CharFilter, Tokenizer TokenFilter, and corresponding 
factories.
Currently we ship schema.xml that contains lines like:

<charFilter class="com.basistech.rlp.solr.RCLUNormalizeCharFilterFactory"
           rlpContext="solr/conf/rlp-context-rclu.xml"/>

This only works if Solr is started from $SOLR_HOME/example, as it is 
relative to the current working directory.
Our customers have to adjust the value to the absolute path if they'd 
like to use Tomcat or any other web container other than Solr builtin 
jetty.
We'd rather like to write something like this:

<charFilter class="com.basistech.rlp.solr.RCLUNormalizeCharFilterFactory"
           rlpContext="${solr.conf.dir}/rlp-context-rclu.xml"/>

Kuro


Re: predefined variables usable in schema.xml ?

Posted by "T. Kuro Kurosaka" <ku...@basistech.com>.
Sorry, correction.
${solr.core.instanceDir} is working in a sense.  It is replaced by the 
core name, rather than a directory path.
In an earlier startup time Solr prints out:
INFO: Creating SolrCore 'collection1' using instanceDir: solr/collection1
But judging from the error message I get, ${solr.core.instanceDir} is 
replaced by the value "collection1"  (no "solr/").

I was hoping that ${solr.core.instanceDir} would be replaced by the 
absolute path to the examples/core/collection1 directory.

On 11/30/12 2:41 PM, T. Kuro Kurosaka wrote:
> I tried to use ${solr.core.instanceDir} in schema.xml with Solr 4.0, 
> where every deployment is multi-core, and it didn't work.
> It must be that the description about pre-defined properties in 
> CoreAdmin wiki page is wrong, or it only works in solrconfig.xml, 
> perhaps?
>
> On 11/28/12 5:17 PM, T. Kuro Kurosaka wrote:
>> Thank you, Hoss.
>>
>> I found this SolrWiki page talks about pre-defined properties such as 
>> solr.core.instanceDir:
>> http://wiki.apache.org/solr/CoreAdmin
>>
>> I tried to use ${solr.core.instanceDir} in the default single-core 
>> schema.xml, and it didn't work.
>> Is this page wrong, or these properties are available only in 
>> multi-core deployments?
>>
>> On 11/27/12 2:27 PM, Chris Hostetter wrote:
>>> : The default solrconfig.xml seems to suggest ${solr.data.dir} can 
>>> be used.
>>> : So I am hoping there is another pre-defined variable like this 
>>> that points to
>>> : the solr core directory.
>>>
>>> there's nothing special about solr.data.dir ... it's used i nthe 
>>> example
>>> configs as a convinient way to let you override it on the command line
>>> when running the example, otherwise it defaults to the empty string 
>>> which
>>> triggers the default dataDir logic (ie: ./data in the instanceDir)...
>>>
>>> <dataDir>${solr.data.dir:}</dataDir>
>>>
>>> :<charFilter 
>>> class="com.basistech.rlp.solr.RCLUNormalizeCharFilterFactory"
>>> :           rlpContext="solr/conf/rlp-context-rclu.xml"/>
>>> :
>>> : This only works if Solr is started from $SOLR_HOME/example, as it 
>>> is relative
>>> : to the current working directory.
>>>
>>> if your factories are using the SolrResourceLoader.openResource to load
>>> those files then you can change that to just be 
>>> 'rlpContext="rlp-context-rclu.xml"'
>>> and it will just plain work -- the SolrResourceLoader is
>>> SolrCloud/ZooKeeper aware, and in stadalone mode checks the conf dir,
>>> the classpath, and as a last resort attempts to resolve it as an 
>>> relative
>>> path -- if your custom factories just call "new File(rlpContext)" on 
>>> the
>>> string, then you're stuck using absolute paths, or needing to define
>>> system properties at runtime.
>>>
>>>
>>> -Hoss
>>
>


Re: predefined variables usable in schema.xml ?

Posted by "T. Kuro Kurosaka" <ku...@basistech.com>.
I tried to use ${solr.core.instanceDir} in schema.xml with Solr 4.0, 
where every deployment is multi-core, and it didn't work.
It must be that the description about pre-defined properties in 
CoreAdmin wiki page is wrong, or it only works in solrconfig.xml, perhaps?

On 11/28/12 5:17 PM, T. Kuro Kurosaka wrote:
> Thank you, Hoss.
>
> I found this SolrWiki page talks about pre-defined properties such as 
> solr.core.instanceDir:
> http://wiki.apache.org/solr/CoreAdmin
>
> I tried to use ${solr.core.instanceDir} in the default single-core 
> schema.xml, and it didn't work.
> Is this page wrong, or these properties are available only in 
> multi-core deployments?
>
> On 11/27/12 2:27 PM, Chris Hostetter wrote:
>> : The default solrconfig.xml seems to suggest ${solr.data.dir} can be 
>> used.
>> : So I am hoping there is another pre-defined variable like this that 
>> points to
>> : the solr core directory.
>>
>> there's nothing special about solr.data.dir ... it's used i nthe example
>> configs as a convinient way to let you override it on the command line
>> when running the example, otherwise it defaults to the empty string 
>> which
>> triggers the default dataDir logic (ie: ./data in the instanceDir)...
>>
>> <dataDir>${solr.data.dir:}</dataDir>
>>
>> :<charFilter 
>> class="com.basistech.rlp.solr.RCLUNormalizeCharFilterFactory"
>> :           rlpContext="solr/conf/rlp-context-rclu.xml"/>
>> :
>> : This only works if Solr is started from $SOLR_HOME/example, as it 
>> is relative
>> : to the current working directory.
>>
>> if your factories are using the SolrResourceLoader.openResource to load
>> those files then you can change that to just be 
>> 'rlpContext="rlp-context-rclu.xml"'
>> and it will just plain work -- the SolrResourceLoader is
>> SolrCloud/ZooKeeper aware, and in stadalone mode checks the conf dir,
>> the classpath, and as a last resort attempts to resolve it as an 
>> relative
>> path -- if your custom factories just call "new File(rlpContext)" on the
>> string, then you're stuck using absolute paths, or needing to define
>> system properties at runtime.
>>
>>
>> -Hoss
>


Re: predefined variables usable in schema.xml ?

Posted by "T. Kuro Kurosaka" <ku...@basistech.com>.
Thank you, Hoss.

I found this SolrWiki page talks about pre-defined properties such as 
solr.core.instanceDir:
http://wiki.apache.org/solr/CoreAdmin

I tried to use ${solr.core.instanceDir} in the default single-core 
schema.xml, and it didn't work.
Is this page wrong, or these properties are available only in multi-core 
deployments?

On 11/27/12 2:27 PM, Chris Hostetter wrote:
> : The default solrconfig.xml seems to suggest ${solr.data.dir} can be used.
> : So I am hoping there is another pre-defined variable like this that points to
> : the solr core directory.
>
> there's nothing special about solr.data.dir ... it's used i nthe example
> configs as a convinient way to let you override it on the command line
> when running the example, otherwise it defaults to the empty string which
> triggers the default dataDir logic (ie: ./data in the instanceDir)...
>
>    <dataDir>${solr.data.dir:}</dataDir>
>
> :<charFilter class="com.basistech.rlp.solr.RCLUNormalizeCharFilterFactory"
> :           rlpContext="solr/conf/rlp-context-rclu.xml"/>
> :
> : This only works if Solr is started from $SOLR_HOME/example, as it is relative
> : to the current working directory.
>
> if your factories are using the SolrResourceLoader.openResource to load
> those files then you can change that to just be 'rlpContext="rlp-context-rclu.xml"'
> and it will just plain work -- the SolrResourceLoader is
> SolrCloud/ZooKeeper aware, and in stadalone mode checks the conf dir,
> the classpath, and as a last resort attempts to resolve it as an relative
> path -- if your custom factories just call "new File(rlpContext)" on the
> string, then you're stuck using absolute paths, or needing to define
> system properties at runtime.
>
>
> -Hoss


Re: predefined variables usable in schema.xml ?

Posted by Chris Hostetter <ho...@fucit.org>.
: The default solrconfig.xml seems to suggest ${solr.data.dir} can be used.
: So I am hoping there is another pre-defined variable like this that points to
: the solr core directory.

there's nothing special about solr.data.dir ... it's used i nthe example 
configs as a convinient way to let you override it on the command line 
when running the example, otherwise it defaults to the empty string which 
triggers the default dataDir logic (ie: ./data in the instanceDir)...

  <dataDir>${solr.data.dir:}</dataDir>

: <charFilter class="com.basistech.rlp.solr.RCLUNormalizeCharFilterFactory"
:           rlpContext="solr/conf/rlp-context-rclu.xml"/>
: 
: This only works if Solr is started from $SOLR_HOME/example, as it is relative
: to the current working directory.

if your factories are using the SolrResourceLoader.openResource to load 
those files then you can change that to just be 'rlpContext="rlp-context-rclu.xml"' 
and it will just plain work -- the SolrResourceLoader is 
SolrCloud/ZooKeeper aware, and in stadalone mode checks the conf dir, 
the classpath, and as a last resort attempts to resolve it as an relative 
path -- if your custom factories just call "new File(rlpContext)" on the 
string, then you're stuck using absolute paths, or needing to define 
system properties at runtime.


-Hoss