SolrClient::setResponseWriter

(PECL solr >= 0.9.11)

SolrClient::setResponseWriterSets the response writer used to prepare the response from Solr

说明

public SolrClient::setResponseWriter ( string $responseWriter ) : void

Sets the response writer used to prepare the response from Solr

参数

responseWriter

One of the following:

  • json
  • phps
  • xml

返回值

没有返回值。

范例

Example #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);

}

?>

相关文章
php dateinterval sets up a dateinterval from the relative parts of the stringphp mcve 函数 get a specific cell from a comma delimited response by column namephp mcve 函数 get a specific cell from a comma delimited response by column numberphp mcve 函数 returns array of strings which represents the keys that can be used for response parameters on this transactionphp mysqlnd ms 函数 sets the quality of service needed from the clusterphp paradox 函数 sets the file where blobs are read fromphp gmagickdraw sets the width of the stroke used to draw object outlinesphp imagickdraw sets the fill color to be used for drawing filled objectsphp imagickdraw sets the color used for stroking object outlinesphp mongocommandcursor create a new command cursor from an existing command response documentphp mysqlnduhconnection prepare next result from multi queryphp solrclient get document by id. utilizes solr realtime get rtg php solrclient get documents by their ids. utilizes solr realtime get rtg php solrclient sets the response writer used to prepare the response from solrphp solrquery sets the minimum document frequency used for determining term countphp solrquery if true the result of the first field grouping command is used as the main result list in the response using group.format=simplephp solrquery sets the name of the field to get the terms fromphp splfileinfo sets the class used with splfileinfo openfilephp splfileinfo sets the class used with splfileinfo getfileinfo and splfileinfo getpathinfophp zookeeper sets the stream to be used by the library for logging
关注编程学问公众号