To transform the Solr default search results from JSON to XML Atom, you create an XSL file. Solr provides example files that you can customize for your server.
- Find a sample Atom XSL file from the Solr distribution at solr.6.5.1/server/solr/configsets/sample_techproducts_configs/xslt/example_atom.xsl.
- Save the file in the xslt folder that has the example xsl file.
- In the
entrysection, edit thename,features, andtimestampnames of thetitle,summary, andupdatedfields, respectively. This section transforms the search results into Atom. When changing the names, review the example XML files in the solr.6.5.1/example/exampledocs folder created when Solr was installed. Or run a search against Solr, and review the JSON search results.
Example
Here’s an example of an Atom XSL file.
<!-- search results xslt -->
<xsl:template match="doc">
<xsl:variable name="id" select="str[@name='id']"/>
<entry>
<title><xsl:value-of select="str[@name='name']"/></title>
<link href="http://localhost:8983/solr/select?q={$id}"/>
<id>tag:localhost,2007:<xsl:value-of select="$id"/></id>
<summary><xsl:value-of select="arr[@name='features']"/></summary>
<updated><xsl:value-of select="date[@name='timestamp']"/></updated>
</entry>
</xsl:template>