The XML Response Writer is the most general purpose and reusable Response Writer currently provided with Solr. It is the format used in most discussions and documentation about the response of Solr queries.

Note that the XsltResponseWriter can be used to convert the XML produced by this writer to other vocabularies or text-based formats.


The behavior of the XML Response Writer can be driven by the following query paramaters.


The version parameter determines the XML protocol used in the response. Clients are strongly encouraged to always specify the protocol version, so as to ensure that the format of the response they receive does not change unexpectedly if/when the Solr server is upgraded.


An <arr> tag was used for multiValued fields only if there was more then one value

/!\ not supported in Solr 4.0+


An <arr> tag is used for multiValued fields even if there is only one value

/!\ not supported in Solr 4.0+


The format of the responseHeader changed to use the same <lst> structure as the rest of the response

The default value is the latest supported


The stylesheet parameter can be used to direct Solr to include a <?xml-stylesheet type="text/xsl" href="..."?> declaration in the XML response it returns.

The default behavior is not to return any stylesheet declaration at all.

Use of the stylesheet param is currently discuraged, as there is currently no way to specify external stylesheets, and no stylesheets are provided in the Solr distributions (it is a legacy param which will hopefully be revived and given new life at some point in the future)


If the indent parameter is used, and it is not "off" and has a non-blank value, then Solr will make some attempts at indenting the XML response such that it will be easier to read by humans.

The default behavior is not to indent.

'newline/line_break character'

When your output contains newline character (Windows = CRLF, Linux=LF, MAC=CR as far as we know), the xml output in browser won't show line break effect. If you select 'view source', you can see there're indeed line break, though, i.e. Solr doesn't affect stored data). For other writer types, such as php, json, csv ,etc, they don't have this problem (json writer type even escapes newline). People normally read data from solr and show html page, if this is your request, you can use regular expression to replace newline with <br> tag, e.g. value.replaceWith("/\r\n/", "<br>").replaceWith("/(?!\r)\n/","<br>").replaceWith("/\r(?!\n)/","<br>"). Adapt the syntax to the language you use before you execute this statement.


XMLResponseFormat (last edited 2013-05-29 21:36:29 by Upayavira)