xmlsolrsolrconfig

Solr - Solrconfig.xml variable is not parsing using <xi:include href=""


Im trying to parse solr variable to include differnet database settings depending on a variable.

-Dsolr.host=dev2.cr9

In solr log I got this exception

Exception during parsing file: solrconfig.xml:org.xml.sax.SAXParseException; systemId: solrres:/solrconfig.xml; lineNumber: 91;

columnNumber: 123; An include with href 'file:///var/lib/solr/conf/database.dih.${solr.host}.xml'failed,​ and no fallback element was found.

How can I parse solr variable href -> using <xi:include href=""


Solution

  • I have done it in a different way.

    The following sample attempts to include database.dih.prod.cr.xml If it doesn't exist or can't be loaded then database.dih.dev.cr.xml will be used instead.

    solrconfig.xml

     <!--- including database config -->
        <xi:include href="file:///var/lib/solr/conf/database.dih.prod.cr.xml"  xmlns:xi="http://www.w3.org/2001/XInclude">
           <xi:fallback>
              <xi:include href="file:///var/lib/solr/conf/database.dih.dev.cr.xml" />
          </xi:fallback>
       </xi:include>
    

    database.dih.web0.psnt.xml

    <requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
          <lst name="defaults">
             <str name="config">data-config.xml</str>
                 <lst name="datasource">
                 <str name="driver">org.mariadb.jdbc.Driver</str>
                 <str name="url">jdbc:mysql://localhost:3306database_name</str>
                 <str name="user">userName</str>
                 <str name="password">password</str>
          </lst>
        </lst>
     </requestHandler>