array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'solrclient.setresponsewriter.php', 1 => 'SolrClient::setResponseWriter', 2 => 'Sets the response writer used to prepare the response from Solr', ), 'up' => array ( 0 => 'class.solrclient.php', 1 => 'SolrClient', ), 'prev' => array ( 0 => 'solrclient.rollback.php', 1 => 'SolrClient::rollback', ), 'next' => array ( 0 => 'solrclient.setservlet.php', 1 => 'SolrClient::setServlet', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/solr/solrclient/setresponsewriter.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>
(PECL solr >= 0.9.11)
SolrClient::setResponseWriter — Sets the response writer used to prepare the response from Solr
Sets the response writer used to prepare the response from Solr
responseWriter
One of the following:
json
phps
xml
没有返回值。
示例 #1 SolrClient::setResponseWriter() example
<?php
// This is my custom class for objects
class SolrClass
{
public $_properties = array();
public function __get($property_name) {
if (property_exists($this, $property_name)) {
return $this->$property_name;
} else if (isset($_properties[$property_name])) {
return $_properties[$property_name];
}
return null;
}
}
$options = array
(
'hostname' => 'localhost',
'port' => 8983,
'path' => '/solr/core1'
);
$client = new SolrClient($options);
$client->setResponseWriter("json");
//$response = $client->ping();
$query = new SolrQuery();
$query->setQuery("*:*");
$query->set("objectClassName", "SolrClass");
$query->set("objectPropertiesStorageMode", 1); // 0 for independent properties, 1 for combined
try
{
$response = $client->query($query);
$resp = $response->getResponse();
print_r($response);
print_r($resp);
} catch (Exception $e) {
print_r($e);
}
?>