Unless I'm mistaken, the intended use of the solrconfig_extra.xml file was to be able to easily add configuration options to solrconfig.xml without needing to edit that file directly. (If I am mistaken, please just tell me and close here.)
This is, however, currently not possible. Files included with xi:include must be well-formed, valid XML files (unless they should just be included as unparsed text data, but this is of course useless here). Specifically that means that they must have a single root element. Since we require a <searchComponent name="spellcheck"> definition to be present there, that root element is already taken, and no others can be added. (And even if we'd move the spellcheck definition out of the include (we could easily just make the name of the spellcheck component a property and allow the optional adding of an additional component that should be used instead of our default), it would still be impossible to add more than one configuration option element in that file.

Normally, using an xpointer() for the include would be a (more or less) easy solution for this – however, the default parser used by Solr annoyingly doesn't support that (see last note for the XInclude description in the Solr wiki). Without it, I don't see any solution for this. I tried just using a <config> root element for the solrconfig_extra.xml, but while that parses fine, Solr doesn't seem to recognize/parse the elements within that nested <config> element.

Note, however, that the restriction does not apply to the provided fallback! We could add as many elements there as we'd like. However, that of course completely defeats the purpose.

So, to summarize: I have no idea how we could actually make that concept work in a meaningful way (at least as long as I understand the intention correctly).

Comments

Nick_vh’s picture

I tested this and it's true. You can basically only add spellcheck information there as it only allows one root-element. Should we rename this then?

drunken monkey’s picture

I'd rather think we should document it (if we can't fix it in any way). Renaming the file might make updating unnecessarily complicated for users and while it adds a bit of clarity, I don't think that's worth it.

janusman’s picture

Could this work? Adding to the first line of the solrconfig_extra.xml file, trying to add a never-existing file... and then putting the relevant bits in the section?

<xi:include href="ThisFileDoesNotExist-ItsJustAHack.txt">
  <xi:fallback>

    <searchComponent name="spellcheck_FOO" class="solr.SpellCheckComponent">
        { ... stuff deleted ... }
    </searchComponent>
...

    <!-- Close out with the proper sections too -->
  </xi:fallback>
</xi:include>
janusman’s picture

Status: Active » Needs review
drunken monkey’s picture

Wow. As crazy as it is, that does indeed work! Brilliant idea, janusman, thanks!

So, should we maybe document this somewhere? Maybe explain it in detail in the Search API Solr handbook and link to that from a comment in the file? Or just explain it directly in that file? Or just link to this issue?

damontgomery’s picture

I had to use the following so that solr knew what xi was,
<xi:include href="ThisFileDoesNotExist-ItsJustAHack.txt" xmlns:xi="http://www.w3.org/2001/XInclude">