From 32778b73bb717d5044cfee2d24b2113398ea3b7c Mon Sep 17 00:00:00 2001 From: Israel Ekpo Date: Wed, 28 Oct 2009 02:54:42 +0000 Subject: [PATCH] Adding examples on how to connect to Solr servers behind SSL-enabled containers Examples also illustrate the new options for the SolrClient constructor. - secure (Boolean value indicating whether or not to connect in secure mode) - timeout (This is maximum time in seconds allowed for the http data transfer operation. Default is 30 seconds) - ssl_cert (File name to a PEM-formatted file containing the private key + private certificate (concatenated in that order) ) - ssl_key (File name to a PEM-formatted private key file only) - ssl_keypassword (Password for private key) - ssl_cainfo (Name of file holding one or more CA certificates to verify peer with) - ssl_capath (Name of directory holding multiple CA certificates to verify peer with ) git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@290013 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/solr/examples.xml | 130 +++++++++++++++++++++++- reference/solr/solrclient/construct.xml | 33 ++++-- 2 files changed, 150 insertions(+), 13 deletions(-) diff --git a/reference/solr/examples.xml b/reference/solr/examples.xml index a6670bc576..6f4fe82bbc 100755 --- a/reference/solr/examples.xml +++ b/reference/solr/examples.xml @@ -3,9 +3,61 @@ &reftitle.examples; - - Examples of how to use the Apache Solr extension in PHP - + + + Examples of how to use the Apache Solr extension in PHP + + + Contents of the BootStrap file + + + +]]> + + + + Adding a document to the index @@ -704,6 +756,78 @@ SolrObject Object + + Connecting to SSL-Enabled Server + + SOLR_SERVER_HOSTNAME, + 'login' => SOLR_SERVER_USERNAME, + 'password' => SOLR_SERVER_PASSWORD, + 'port' => SOLR_SERVER_PORT, + 'timeout' => SOLR_SERVER_TIMEOUT, + 'secure' => SOLR_SECURE, + 'ssl_cert' => SOLR_SSL_CERT_ONLY, + 'ssl_key' => SOLR_SSL_KEY, + 'ssl_keypassword' => SOLR_SSL_KEYPASSWORD, + 'ssl_cainfo' => SOLR_SSL_CAINFO, +); + +$client = new SolrClient($options); + +$query = new SolrQuery('*:*'); + +$query->setFacet(true); + +$query->addFacetField('cat')->addFacetField('name')->setFacetMinCount(2)->setFacetMinCount(4, 'name'); + +$updateResponse = $client->query($query); + +$response_array = $updateResponse->getResponse(); + +$facet_data = $response_array->facet_counts->facet_fields; + +print_r($facet_data); + +?> +]]> + + &example.outputs.similar; + + SolrObject Object + ( + [electronics] => 14 + [memory] => 3 + [Lucene] => 2 + [Software] => 2 + [card] => 2 + [connector] => 2 + [drive] => 2 + [graphics] => 2 + [hard] => 2 + [monitor] => 2 + [search] => 2 + [software] => 2 + ) + + [name] => SolrObject Object + ( + [gb] => 6 + ) + +) +]]> + + +