Confluence has been migrated and upgraded. Please file an INFRA ticket if you see any issues.
This can be used to generate any text-based format from the Solr query results, as the Content-Type of the response is supplied by the XSLT transform, as shown below.
With Solr's example configuration, this URL uses the XSLT Response Writer with the supplied example.xsl transform:
Selects the XSLT transformation to use, which must be found in Solr's conf/xslt directory.
The Content-Type of the response is set according to the <xsl:output> statement in the XSLT transform, for example:
Note that on Windows, the encoding defaults to 8859-1. To ensure that UTF-8 is used for encoding, use this:
The XSLT Response Writer is configured as in this example (from the default solrconfig.xml):
A value of 5 for xsltCacheLifetimeSeconds is good for development, to see XSLT changes quickly. For production you probably want a much higher value.
The last XSLT transform used is cached, and reread and recompiled every xsltCacheLifetimeSeconds, even if it has not changed. This simplistic caching mechanism is good enough in many cases, but heavy use of XSLT transforms might require implementing a better caching mechanism (or shameless plug put Cocoon in front of Solr for more serious XSLT-based stuff).
When first used, the XSLT Response Writer outputs the following warning to the Solr log, to make sure you're aware of this limitation:
Also, the output of the XML Response Writer is captured in memory for the XSLT transform. Big results set could cause high RAM usage.
The performance of XSLT transforms can vary dramatically depending on how well they're written - you've been warned.
Using Saxon for XSLT 2.0 Transforms
The XsltResponseWriter can easily be changed to use other transformers. The Saxon-B open source XSL transformer supports XSL 2.0 features, such as URI encoding, time and date functions, and field grouping. To change the default transformer to use Saxon, simply copy the Saxon .jar files into your classpath and set the system property javax.xml.TransformerFactory to "net.sf.saxon.TransfomerFactoryImpl". No changes to the Solr source are needed.
For Jetty (in the Solr example), make sure all the saxon-*.jars are in Jetty's ext/ folder (or lib/ext folder in current version of Jetty), and start Jetty like:
For Resin, put this in your resin.conf:
Now that you've got Saxon-B running, make sure your XSL files state the right version:
and you can use the best new feature for Solr users of XSL, for-each-grouping. Here I'll group by the Solr field 'username' and show the "comments" field per document:
With Saxon installed you can create valid RSS using the date functionality. (http://www.w3.org/TR/xslt20/#function-format-date)
Call this with something like: