I'm currently using a Solr implementation inside of Riak KV server. In respect of Riak defaults and not to fear any software ugrade I need to include extra configuration into my core SolrConfig.xml. I'll be doing this programmatically through Ansible command. I want to add as few line as possible in the factory settings solrconfig.xml.
I need to include a bunch of <searchComponent> and <requestHandler> inside my config, for that I was wishing to use this kind of pattern:
<config>
<!-- snip -->
<xi:include href="solrconfig_extra.xml" xpointer="xpointer(//searchComponent)" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="solrconfig_extra.xml" xpointer="xpointer(//requestHandler)" xmlns:xi="http://www.w3.org/2001/XInclude" />
</config>
with a configuration file looking like this:
<?xml version="1.0" encoding="UTF-8" ?>
<container>
<searchComponent class="solr.SpellCheckComponent" name="suggest">
<lst name="spellchecker">
<str name="name">suggest</str>
<str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
<str name="lookupImpl">org.apache.solr.spelling.suggest.tst.TSTLookupFactory</str>
<str name="field">myterms</str> <!-- the indexed field to derive suggestions from -->
<float name="threshold">0</float>
<str name="buildOnCommit">false</str>
<!--
<str name="sourceLocation">american-english</str>
-->
</lst>
</searchComponent>
<requestHandler class="org.apache.solr.handler.component.SearchHandler" name="/suggest">
<lst name="defaults">
<str name="spellcheck">true</str>
<str name="spellcheck.dictionary">suggest</str>
<str name="spellcheck.onlyMorePopular">true</str>
<str name="spellcheck.count">5</str>
<str name="spellcheck.collate">true</str>
</lst>
<arr name="components">
<str>suggest</str>
</arr>
</requestHandler>
</container>
Unfortunately, Xerces don't support the xpointer() schema, and as the element() only accept element index, and would require as much insert as the include container has children.
How can I achieve this inclusion in an orderly manner ?
- Is it easy to switch from xerces to another xmlparser ? I must remind you that I don't want to alter vendor solution as much as possible.
- In SolrConfig grammar there is maybe a neutral element that would allow me to be included in configuration (for instance /config/NEUTRALMAGICTAG/requestHandler to be interpreted as /config/requestHandler )
- Should I renounce and forget about XInclude and work my way through pure ansible file edition ?
TYPO3 uses XML includes for the Solr configuration. This might be helpful.
Beware though that the latest Solr uses dynamic schemas, which may rewrite the files with all the various includes into a unified managed-schema file (e.g. for schemaless mode). You can disable it or never trigger the rewrite, just need to be deliberate about it.