11.05.2016 Views

Apache Solr Reference Guide Covering Apache Solr 6.0

21SiXmO

21SiXmO

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<br />

text/plain<br />

<br />

Python Response Writer<br />

<strong>Solr</strong> has an optional Python response format that extends its JSON output in the following ways to allow the<br />

response to be safely evaluated by the python interpreter:<br />

true and false changed to True and False<br />

Python unicode strings are used where needed<br />

ASCII output (with unicode escapes) is used for less error-prone interoperability<br />

newlines are escaped<br />

null changed to None<br />

PHP Response Writer and PHP Serialized Response Writer<br />

<strong>Solr</strong> has a PHP response format that outputs an array (as PHP code) which can be evaluated. Setting the wt par<br />

ameter to php invokes the PHP Response Writer.<br />

Example usage:<br />

$code =<br />

file_get_contents('http://localhost:8983/solr/techproducts/select?q=iPod&wt=php');<br />

eval("$result = " . $code . ";");<br />

print_r($result);<br />

<strong>Solr</strong> also includes a PHP Serialized Response Writer that formats output in a serialized array. Setting the wt par<br />

ameter to phps invokes the PHP Serialized Response Writer.<br />

Example usage:<br />

$serializedResult =<br />

file_get_contents('http://localhost:8983/solr/techproducts/select?q=iPod&wt=phps');<br />

$result = unserialize($serializedResult);<br />

print_r($result);<br />

Ruby Response Writer<br />

<strong>Solr</strong> has an optional Ruby response format that extends its JSON output in the following ways to allow the<br />

response to be safely evaluated by Ruby's interpreter:<br />

Ruby's single quoted strings are used to prevent possible string exploits.<br />

\ and ' are the only two characters escaped.<br />

Unicode escapes are not used. Data is written as raw UTF-8.<br />

nil used for null.<br />

=> is used as the key/value separator in maps.<br />

<strong>Apache</strong> <strong>Solr</strong> <strong>Reference</strong> <strong>Guide</strong> <strong>6.0</strong><br />

395

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!