SolrClient::setResponseWriter

(PECL solr >= 0.9.11)
Sets the response writer used to prepare the response from Solr
public void SolrClient::setResponseWriter ( string $responseWriter )

Sets the response writer used to prepare the response from Solr

Parameters:
responseWriter

One of the following:

  • json
  • phps
  • xml
Returns:

No value is returned.

Examples:
SolrClient::setResponseWriter() example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?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);
 
}
 
?>
doc_php
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.