Apache Solr SolrClient::setResponseWriter

(PECL solr >= 0.9.11)

SolrClient::setResponseWriter — Solr의 응답을 준비하는 데 사용되는 응답 작성기를 설정합니다.


설명

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

Solr의 응답을 준비하는 데 사용되는 응답 작성기를 설정합니다.


매개변수

responseWriter
다음 중 하나:
  • json
  • phps
  • xml

반환 값

값이 반환되지 않습니다.


Examples

예제 #1 SolrClient::setResponseWriter() 예제

                  
<?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);

}

?>