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 eventhttpconnection sets the ip address from which http connections are madephp eventhttpconnection sets the local port from which connections are madephp mcve 函数 returns array of strings which represents the keys that can be used for response parameters on this transactionphp maxdb 函数 prepare next result from multi queryphp oci8 函数 returns the next child statement resource from a parent statement resource that has oracle database 12c implicit result setsphp paradox 函数 sets the file where blobs are read fromphp gmagickdraw sets the color used for stroking object outlinesphp gmagickdraw sets the width of the stroke used to draw object outlinesphp imagickdraw sets the color used for stroking object outlinesphp intldateformatter sets the calendar type used by the formatterphp mongocommandcursor create a new command cursor from an existing command response documentphp soapclient returns the soap headers from the last responsephp soapserver sets the object which will be used to handle soap requestsphp solrclient get document by id. utilizes solr realtime get rtg php solrclient sets the response writer used to prepare the response from solrphp solrclient retrieve solr server informationphp solrpingresponse returns the response from the serverphp 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 factor by which the regex fragmenter can stray from the ideal fragment sizephp solrresponse returns a solrobject representing the xml response from the server
关注编程学问公众号