A relatively unknown, but powerful way to integrate with Solr is via its support for
XSLT (eXtensible Stylesheet Language Transformations). XSLT is a specification for transforming XML documents into other XML formats, which includes HTML. There are various implementations of this specification and Java includes one. Solr provides a query response writer that executes a provided XSLT stylesheet to transform Solr's XML search results into some other format. Solr comes with a couple of examples in ./conf/xslt/
. Here is an example of transforming search results into an RSS feed:
http://localhost:8983/solr/mbartists/select/?q=marley&wt=xslt&tr=example_rss.xsl
The wt
parameter triggers the use of XSLT, and the tr
parameter supplies the name of the stylesheet to be used.
There are some caveats to keep in mind for XSLT support. Internally, XSLT files are compiled before they are used, and while Solr will cache the last compiled XSLT for a period...