### Eclipse Workspace Patch 1.0 #P lyrics-vu Index: sites/all/modules/apachesolr/apachesolr_search.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/apachesolr_search.module,v retrieving revision 1.6 diff -u -r1.6 apachesolr_search.module --- sites/all/modules/apachesolr/apachesolr_search.module 28 Aug 2008 12:46:56 -0000 1.6 +++ sites/all/modules/apachesolr/apachesolr_search.module 5 Sep 2008 08:38:24 -0000 @@ -46,18 +46,72 @@ try { $params = apachesolr_search_get_params(); - $response = $solr->search($query->get_query(), $params['start'], $params['rows'], $params); + + // Enable spellchecker + $search_servlet = null; + if(variable_get('apachesolr_spellchecker', false)) { + + //Add new parameter to the search request + $params['spellcheck.q'] = $query->get_query(); + $params['spellcheck'] = 'true'; + + //Set the spellchecker component request handler + $search_servlet = variable_get('apachesolr_searchservlet', '/spellCheckCompRH'); + + } + + //Enable highlighting + if(variable_get('apachesolr_solrhighlighting', false)) { + + //Add new parameter to the search request + $params['hl'] = 'true'; + $params['hl.fragsize']= variable_get('apachesolr_textsnippetlength', 100); + $params['hl.simple.pre'] = ''; + $params['hl.simple.post'] = ''; + + } + + $response = $solr->search($query->get_query(), $params['start'], $params['rows'], $params, $search_servlet); + + //Get suggestion into an array + $suggestionresults = get_object_vars($response->spellcheck->suggestions); + + //If there are any suggestions + if($suggestionresults) { + + //Prepage original query and replace wrong words + global $suggestions; + $suggestions = $query->get_query(); + + foreach($suggestionresults as $word => $value) { + $suggestions = str_replace($word, $value->suggestion[0], $suggestions); + } + } + apachesolr_has_searched(TRUE); + + //New since json_decode + $highlight = $response->highlighting; + $response = $response->response; + $total = $response->numFound; // The response is cached so that it is accessible to the blocks and anything // else that needs it beyond the initial search. apachesolr_static_response_cache($response); pager_query("SELECT %d", $params['rows'], 0, NULL, $total); if ($total > 0) { - foreach ($response->documents as $doc) { + foreach ($response->docs as $doc) { + $extra = node_invoke_nodeapi($doc, 'search result'); $extra['score'] = $doc->score; - $snippet = search_excerpt($keys, $doc->body); + + if(variable_get('apachesolr_solrhighlighting', false)){ + $snippet = each($highlight); + $snippet = $snippet['value']->text[0]; + } + else + $snippet = search_excerpt($keys, $doc->body); + if (trim($snippet) == '...') { $snippet = ''; } @@ -70,6 +124,7 @@ 'extra' => $extra, 'score' => $doc->score, 'snippet' => $snippet); + } // Hook to allow modifications of the retrieved results @@ -102,7 +157,7 @@ 'facet' => 'true', 'facet.field' => array('tid', 'type', 'uid', 'language'), 'facet.mincount' => 1, - 'facet.sort' => 'true' + 'facet.sort' => 'true', ); // Facet limits @@ -125,3 +180,64 @@ return $params; } + + +/** + * Implementation of hook_form_alter(). + * + * This allows to add spell suggestions + */ +function apachesolr_search_form_alter(&$form, $form_state, $form_id) { + // Normally a switch is used because you may want to alter more than + // one form and it is easy to add a new case for each form. + switch ($form_id) { + // This is our form ID. + case 'search_form': + + global $suggestions; + + if($suggestions) { + $item['suggestion'] = array( + '#prefix' => '
', + '#suffix' => '
', + '#type' => 'item', + '#title' => t('Did you mean'), + '#value' => l($suggestions, 'search/'.$form['module']['#value'].'/'.$suggestions), + ); + + $form['basic']['inline']['suggestions'] = $item; + } + //return print_r($form); + break; + } +} + +/* +* Implementation of hook_cron() +*/ +function apachesolr_search_cron() { + // Rebuild spelling dictionary every 24 hours + $last = variable_get('apachesolr_search_spellrebuildtime', 0); + if (time() < $last+3600*24) { + return; + } + + try { + + //Add new parameter to the search request + $params = array(); + $params['spellcheck'] = 'true'; + $params['spellcheck.build'] = 'true'; + + // Instantiate a new Solr object. + $solr =& apachesolr_get_solr(variable_get('apachesolr_host', 'localhost'), variable_get('apachesolr_port', 8983), variable_get('apachesolr_path', '/solr')); + $solr->search('*:*',0,0,$params, variable_get('apachesolr_searchservlet', 'spellCheckCompRH')); + } + catch (Exception $e) { + watchdog('Apache Solr', $e->getMessage(), NULL, WATCHDOG_ERROR); + } + + // Mark time of last spellchecker rebuild + variable_set('apachesolr_search_spellrebuildtime', time()); +} + Index: sites/all/modules/apachesolr/apachesolr.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/apachesolr.module,v retrieving revision 1.9 diff -u -r1.9 apachesolr.module --- sites/all/modules/apachesolr/apachesolr.module 28 Aug 2008 12:46:56 -0000 1.9 +++ sites/all/modules/apachesolr/apachesolr.module 5 Sep 2008 08:38:24 -0000 @@ -25,6 +25,13 @@ 'access callback' => 'user_access', 'access arguments' => array('administer site configuration'), ); + $items['admin/settings/apachesolr/spellchecker'] = array( + 'title' => 'Spellchecker', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('apachesolr_spellchecker'), + 'access callback' => 'user_access', + 'access arguments' => array('administer site configuration'), + ); return $items; } @@ -49,6 +56,37 @@ '#default_value' => variable_get('apachesolr_path', '/solr'), '#description' => t('Path that identifies the Solr request handler to be used. Leave this as /solr for now.'), ); + $form['apachesolr_solrhighlighting'] = array( + '#type' => 'checkbox', + '#title' => t('Enable highlighting by solr'), + '#default_value' => variable_get('apachesolr_solrhighlighting', false), + '#description' => t('Highlighting and text excerpt is done using solr.'), + ); + + $options = array(); + foreach (array(100, 150, 200, 250, 300, 400, 500, 600) as $option) { + $options[$option] = $option; + } + $form['apachesolr_textsnippetlength'] = array( + '#type' => 'select', + '#title' => t('Length of text snippet in the result'), + '#default_value' => variable_get('apachesolr_textsnippetlength', 100), + '#options' => $options, + '#description' => t('The number of characters the text snippet in the search result will be.'), + ); + $form['apachesolr_onlybodyfield'] = array( + '#type' => 'checkbox', + '#title' => t('Index only body field of node'), + '#default_value' => variable_get('apachesolr_onlybodyfield', false), + '#description' => t('Index only the content of the body field and not the whole content of the page. Useful if you have a lot of views on the node page'), + ); + $form['apachesolr_excludepathalias'] = array( + '#type' => 'checkbox', + '#title' => t('Exclude the path aliases from index'), + '#default_value' => variable_get('apachesolr_excludepathalias', false), + '#description' => t('Exclude path alias from being indexed. Useful if you have hierarchical path aliases'), + ); + $options = array(); foreach (array(5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 60, 70, 80, 90, 100) as $option) { $options[$option] = $option; @@ -63,6 +101,37 @@ return system_settings_form($form); } +function apachesolr_spellchecker() { + + $form = array(); + + $form['apachesolr_spellchecker'] = array( + '#type' => 'checkbox', + '#title' => t('Enable Spellchecker and suggestions'), + '#default_value' => variable_get('apachesolr_spellchecker', false), + '#description' => t('Enable spellchecker an get word suggestions. Also called "Did you mean" function'), + ); + $form['apachesolr_searchservlet'] = array( + '#type' => 'textfield', + '#title' => t('Solr search servlet for spellchecker'), + '#default_value' => variable_get('apachesolr_searchservlet', 'spellCheckCompRH'), + '#description' => t('Spellchecker component of solr using a different servlet for inline suggestions.'), + ); + $form['apachesolr_rebuildspellcheckerindex'] = array( + '#type' => 'checkbox', + '#title' => t('If enabled, the spellchecker index will be rebuild upon submitting the form'), + '#default_value' => variable_get('apachesolr_rebuildspellcheckerindex', false), + '#description' => t('Before the spellchecker can be used, the index of words has to be build.'), + ); + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Submit settings'), + ); + + return $form; +} + + /** * Implementation of hook_requirements(). */ @@ -177,6 +246,35 @@ } } +/* + * Spellchecker setting form + * + */ +function apachesolr_spellchecker_submit($form, &$form_state) { + + //Save variables + variable_set('apachesolr_spellchecker',$form_state['values']['apachesolr_spellchecker']); + variable_set('apachesolr_searchservlet',$form_state['values']['apachesolr_searchservlet']); + variable_set('apachesolr_rebuildspellcheckerindex',false); + + if ($form_state['values']['apachesolr_rebuildspellcheckerindex']) { + try { + + //Add new parameter to the search request + $params = array(); + $params['spellcheck'] = 'true'; + $params['spellcheck.build'] = 'true'; + + // Instantiate a new Solr object. + $solr =& apachesolr_get_solr(variable_get('apachesolr_host', 'localhost'), variable_get('apachesolr_port', 8983), variable_get('apachesolr_path', '/solr')); + $solr->search('*:*',0,0,$params, variable_get('apachesolr_searchservlet', 'spellCheckCompRH')); + } + catch (Exception $e) { + watchdog('Apache Solr', $e->getMessage(), NULL, WATCHDOG_ERROR); + } + } +} + /** * The point of this class is to manage the update index needs of multiple @@ -258,17 +356,21 @@ $node = node_load($row->nid); if ($node->nid) { - // Build the node body. - $node = node_build_content($node, FALSE, FALSE); - $node->body = drupal_render($node->content); + + if(!variable_get('apachesolr_onlybodyfield', false)){ + // Build the node body. + $node = node_build_content($node, FALSE, FALSE); + $node->body = drupal_render($node->content); + } - $text = check_plain($node->title) . $node->body; + $text = check_plain($node->title) .' '. $node->body; + /* // Fetch extra data normally not visible $extra = node_invoke_nodeapi($node, 'update index'); foreach ($extra as $t) { $text .= $t; - } + }*/ // Update solr index. try { @@ -285,16 +387,18 @@ // Path aliases can have important information about the content. // Add them to the index as well. - if (function_exists('drupal_get_path_alias')) { - // Add any path alias to the index, looking first for language specific - // aliases but using language neutral aliases otherwise. - $language = empty($node->language) ? '' : $node->language; - $path = 'node/' . $node->nid; - $output = drupal_get_path_alias($path, $language); - if ($output && $output != $path) { - $document->path = $output; - $text .= $output; - } + if(!variable_get('apachesolr_excludepathalias', false)){ + if (function_exists('drupal_get_path_alias')) { + // Add any path alias to the index, looking first for language specific + // aliases but using language neutral aliases otherwise. + $language = empty($node->language) ? '' : $node->language; + $path = 'node/' . $node->nid; + $output = drupal_get_path_alias($path, $language); + if ($output && $output != $path) { + $document->path = $output; + $text .= $output; + } + } } if ($cck_fields && strpos($key, 'field_') === 0) { Index: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_ServiceBalancer.php.html =================================================================== RCS file: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_ServiceBalancer.php.html diff -N sites/all/modules/apachesolr/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_ServiceBalancer.php.html --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sites/all/modules/apachesolr/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_ServiceBalancer.php.html 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,767 @@ + + + + + + File Source for Balancer.php + + + + + +

Source for file Balancer.php

+

Documentation is available at Balancer.php

+
+
  1. <?php
  2. +
  3. /**
  4. +
  5.  * @copyright Copyright 2007 Conduit Internet Technologies, Inc. (http://conduit-it.com)
  6. +
  7.  * @license Apache Licence, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
  8. +
  9.  *
  10. +
  11.  *  Licensed under the Apache License, Version 2.0 (the "License");
  12. +
  13.  *  you may not use this file except in compliance with the License.
  14. +
  15.  *  You may obtain a copy of the License at
  16. +
  17.  *
  18. +
  19.  *      http://www.apache.org/licenses/LICENSE-2.0
  20. +
  21.  *
  22. +
  23.  *  Unless required by applicable law or agreed to in writing, software
  24. +
  25.  *  distributed under the License is distributed on an "AS IS" BASIS,
  26. +
  27.  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  28. +
  29.  *  See the License for the specific language governing permissions and
  30. +
  31.  *  limitations under the License.
  32. +
  33.  *
  34. +
  35.  * @package Apache
  36. +
  37.  * @subpackage Solr
  38. +
  39.  * @author Donovan Jimenez <djimenez@conduit-it.com>, Dan Wolfe
  40. +
  41.  */
  42. +
  43.  
  44. +
  45. require_once('Apache/Solr/Service.php');
  46. +
  47.  
  48. +
  49. /**
  50. +
  51.  * Reference Implementation for using multiple Solr services in a distribution. Functionality
  52. +
  53.  * includes:
  54. +
  55.  *     routing of read / write operations
  56. +
  57.  *     failover (on selection) for multiple read servers
  58. +
  59.  */
  60. +
  61. +
  62. {
  63. +
  64.     protected $_createDocuments = true;
  65. +
  66.  
  67. +
  68.     protected $_readableServices = array();
  69. +
  70.     protected $_writeableServices = array();
  71. +
  72.  
  73. +
  74.     protected $_currentReadService = null;
  75. +
  76.     protected $_currentWriteService = null;
  77. +
  78.  
  79. +
  80.     protected $_readPingTimeout = 2;
  81. +
  82.     protected $_writePingTimeout = 4;
  83. +
  84.     
  85. +
  86.     // Configuration for server selection backoff intervals
  87. +
  88.     protected $_useBackoff = false;        // Set to true to use more resillient write server selection
  89. +
  90.     protected $_backoffLimit = 600;        // 10 minute default maximum
  91. +
  92.     protected $_backoffEscalation = 2.0;     // Rate at which to increase backoff period
  93. +
  94.     protected $_defaultBackoff = 2.0;        // Default backoff interval
  95. +
  96.  
  97. +
  98.     /**
  99. +
  100.      * Escape a value for special query characters such as ':', '(', ')', '*', '?', etc.
  101. +
  102.      *
  103. +
  104.      * NOTE: inside a phrase fewer characters need escaped, use {@link Apache_Solr_Service::escapePhrase()} instead
  105. +
  106.      *
  107. +
  108.      * @param string $value 
  109. +
  110.      * @return string 
  111. +
  112.      */
  113. +
  114.     static public function escape($value)
  115. +
  116.     {
  117. +
  118.         return Apache_Solr_Service::escape($value);
  119. +
  120.     }
  121. +
  122.  
  123. +
  124.     /**
  125. +
  126.      * Escape a value meant to be contained in a phrase for special query characters
  127. +
  128.      *
  129. +
  130.      * @param string $value 
  131. +
  132.      * @return string 
  133. +
  134.      */
  135. +
  136.     static public function escapePhrase($value)
  137. +
  138.     {
  139. +
  140.         return Apache_Solr_Service::escapePhrase($value);
  141. +
  142.     }
  143. +
  144.  
  145. +
  146.     /**
  147. +
  148.      * Convenience function for creating phrase syntax from a value
  149. +
  150.      *
  151. +
  152.      * @param string $value 
  153. +
  154.      * @return string 
  155. +
  156.      */
  157. +
  158.     static public function phrase($value)
  159. +
  160.     {
  161. +
  162.         return Apache_Solr_Service::phrase($value);
  163. +
  164.     }
  165. +
  166.  
  167. +
  168.     /**
  169. +
  170.      * Constructor. Takes arrays of read and write service instances or descriptions
  171. +
  172.      *
  173. +
  174.      * @param array $readableServices 
  175. +
  176.      * @param array $writeableServices 
  177. +
  178.      */
  179. +
  180.     public function __construct($readableServices = array(), $writeableServices = array())
  181. +
  182.     {
  183. +
  184.         //setup readable services
  185. +
  186.         foreach ($readableServices as $service)
  187. +
  188.         {
  189. +
  190.             $this->addReadService($service);
  191. +
  192.         }
  193. +
  194.  
  195. +
  196.         //setup writeable services
  197. +
  198.         foreach ($writeableServices as $service)
  199. +
  200.         {
  201. +
  202.             $this->addWriteService($service);
  203. +
  204.         }
  205. +
  206.     }
  207. +
  208.  
  209. +
  210.     public function setReadPingTimeout($timeout)
  211. +
  212.     {
  213. +
  214.         $this->_readPingTimeout = $timeout;
  215. +
  216.     }
  217. +
  218.  
  219. +
  220.     public function setWritePingTimeout($timeout)
  221. +
  222.     {
  223. +
  224.         $this->_writePingTimeout = $timeout;
  225. +
  226.     }
  227. +
  228.     
  229. +
  230.     public function setUseBackoff($enable)
  231. +
  232.     {
  233. +
  234.         $this->_useBackoff = $enable;
  235. +
  236.     }
  237. +
  238.  
  239. +
  240.     /**
  241. +
  242.      * Generates a service ID
  243. +
  244.      *
  245. +
  246.      * @param string $host 
  247. +
  248.      * @param integer $port 
  249. +
  250.      * @param string $path 
  251. +
  252.      * @return string 
  253. +
  254.      */
  255. +
  256.     protected function _getServiceId($host, $port, $path)
  257. +
  258.     {
  259. +
  260.         return $host . ':' . $port . $path;
  261. +
  262.     }
  263. +
  264.  
  265. +
  266.     /**
  267. +
  268.      * Adds a service instance or service descriptor (if it is already
  269. +
  270.      * not added)
  271. +
  272.      *
  273. +
  274.      * @param mixed $service 
  275. +
  276.      *
  277. +
  278.      * @throws Exception If service descriptor is not valid
  279. +
  280.      */
  281. +
  282.     public function addReadService($service)
  283. +
  284.     {
  285. +
  286.         if ($service instanceof Apache_Solr_Service)
  287. +
  288.         {
  289. +
  290.             $id = $this->_getServiceId($service->getHost(), $service->getPort(), $service->getPath());
  291. +
  292.  
  293. +
  294.             $this->_readableServices[$id] = $service;
  295. +
  296.         }
  297. +
  298.         else if (is_array($service))
  299. +
  300.         {
  301. +
  302.             if (isset($service['host']) && isset($service['port']) && isset($service['path']))
  303. +
  304.             {
  305. +
  306.                 $id = $this->_getServiceId((string)$service['host'], (int)$service['port'], (string)$service['path']);
  307. +
  308.  
  309. +
  310.                 $this->_readableServices[$id] = $service;
  311. +
  312.             }
  313. +
  314.             else
  315. +
  316.             {
  317. +
  318.                 throw new Exception('A Readable Service description array does not have all required elements of host, port, and path');
  319. +
  320.             }
  321. +
  322.         }
  323. +
  324.     }
  325. +
  326.  
  327. +
  328.     /**
  329. +
  330.      * Removes a service instance or descriptor from the available services
  331. +
  332.      *
  333. +
  334.      * @param mixed $service 
  335. +
  336.      *
  337. +
  338.      * @throws Exception If service descriptor is not valid
  339. +
  340.      */
  341. +
  342.     public function removeReadService($service)
  343. +
  344.     {
  345. +
  346.         $id = '';
  347. +
  348.  
  349. +
  350.         if ($service instanceof Apache_Solr_Service)
  351. +
  352.         {
  353. +
  354.             $id = $this->_getServiceId($service->getHost(), $service->getPort(), $service->getPath());
  355. +
  356.         }
  357. +
  358.         else if (is_array($service))
  359. +
  360.         {
  361. +
  362.             if (isset($service['host']) && isset($service['port']) && isset($service['path']))
  363. +
  364.             {
  365. +
  366.                 $id = $this->_getServiceId((string)$service['host'], (int)$service['port'], (string)$service['path']);
  367. +
  368.             }
  369. +
  370.             else
  371. +
  372.             {
  373. +
  374.                 throw new Exception('A Readable Service description array does not have all required elements of host, port, and path');
  375. +
  376.             }
  377. +
  378.         }
  379. +
  380.         else if (is_string($service))
  381. +
  382.         {
  383. +
  384.             $id = $service;
  385. +
  386.         }
  387. +
  388.  
  389. +
  390.         if ($id && isset($this->_readableServices[$id]))
  391. +
  392.         {
  393. +
  394.             unset($this->_readableServices[$id]);
  395. +
  396.         }
  397. +
  398.     }
  399. +
  400.  
  401. +
  402.     /**
  403. +
  404.      * Adds a service instance or service descriptor (if it is already
  405. +
  406.      * not added)
  407. +
  408.      *
  409. +
  410.      * @param mixed $service 
  411. +
  412.      *
  413. +
  414.      * @throws Exception If service descriptor is not valid
  415. +
  416.      */
  417. +
  418.     public function addWriteService($service)
  419. +
  420.     {
  421. +
  422.         if ($service instanceof Apache_Solr_Service)
  423. +
  424.         {
  425. +
  426.             $id = $this->_getServiceId($service->getHost(), $service->getPort(), $service->getPath());
  427. +
  428.  
  429. +
  430.             $this->_writeableServices[$id] = $service;
  431. +
  432.         }
  433. +
  434.         else if (is_array($service))
  435. +
  436.         {
  437. +
  438.             if (isset($service['host']) && isset($service['port']) && isset($service['path']))
  439. +
  440.             {
  441. +
  442.                 $id = $this->_getServiceId((string)$service['host'], (int)$service['port'], (string)$service['path']);
  443. +
  444.  
  445. +
  446.                 $this->_writeableServices[$id] = $service;
  447. +
  448.             }
  449. +
  450.             else
  451. +
  452.             {
  453. +
  454.                 throw new Exception('A Writeable Service description array does not have all required elements of host, port, and path');
  455. +
  456.             }
  457. +
  458.         }
  459. +
  460.     }
  461. +
  462.  
  463. +
  464.     /**
  465. +
  466.      * Removes a service instance or descriptor from the available services
  467. +
  468.      *
  469. +
  470.      * @param mixed $service 
  471. +
  472.      *
  473. +
  474.      * @throws Exception If service descriptor is not valid
  475. +
  476.      */
  477. +
  478.     public function removeWriteService($service)
  479. +
  480.     {
  481. +
  482.         $id = '';
  483. +
  484.  
  485. +
  486.         if ($service instanceof Apache_Solr_Service)
  487. +
  488.         {
  489. +
  490.             $id = $this->_getServiceId($service->getHost(), $service->getPort(), $service->getPath());
  491. +
  492.         }
  493. +
  494.         else if (is_array($service))
  495. +
  496.         {
  497. +
  498.             if (isset($service['host']) && isset($service['port']) && isset($service['path']))
  499. +
  500.             {
  501. +
  502.                 $id = $this->_getServiceId((string)$service['host'], (int)$service['port'], (string)$service['path']);
  503. +
  504.             }
  505. +
  506.             else
  507. +
  508.             {
  509. +
  510.                 throw new Exception('A Readable Service description array does not have all required elements of host, port, and path');
  511. +
  512.             }
  513. +
  514.         }
  515. +
  516.         else if (is_string($service))
  517. +
  518.         {
  519. +
  520.             $id = $service;
  521. +
  522.         }
  523. +
  524.  
  525. +
  526.         if ($id && isset($this->_writeableServices[$id]))
  527. +
  528.         {
  529. +
  530.             unset($this->_writeableServices[$id]);
  531. +
  532.         }
  533. +
  534.     }
  535. +
  536.  
  537. +
  538.     /**
  539. +
  540.      * Iterate through available read services and select the first with a ping
  541. +
  542.      * that satisfies configured timeout restrictions (or the default)
  543. +
  544.      *
  545. +
  546.      * @return Apache_Solr_Service 
  547. +
  548.      *
  549. +
  550.      * @throws Exception If there are no read services that meet requirements
  551. +
  552.      */
  553. +
  554.     protected function _selectReadService($forceSelect = false)
  555. +
  556.     {
  557. +
  558.         if (!$this->_currentReadService || !isset($this->_readableServices[$this->_currentReadService]) || $forceSelect)
  559. +
  560.         {
  561. +
  562.             if ($this->_currentReadService && isset($this->_readableServices[$this->_currentReadService]) && $forceSelect)
  563. +
  564.             {
  565. +
  566.                 // we probably had a communication error, ping the current read service, remove it if it times out
  567. +
  568.                 if ($this->_readableServices[$this->_currentReadService]->ping($this->_readPingTimeout) === false)
  569. +
  570.                 {
  571. +
  572.                     $this->removeReadService($this->_currentReadService);
  573. +
  574.                 }
  575. +
  576.             }
  577. +
  578.             
  579. +
  580.             if (count($this->_readableServices))
  581. +
  582.             {
  583. +
  584.                 // select one of the read services at random
  585. +
  586.                 $ids = array_keys($this->_readableServices);
  587. +
  588.                 
  589. +
  590.                 $id = $ids[rand(0, count($ids) - 1)];
  591. +
  592.                 $service = $this->_readableServices[$id];
  593. +
  594.             
  595. +
  596.                 if (is_array($service))
  597. +
  598.                 {
  599. +
  600.                     //convert the array definition to a client object
  601. +
  602.                     $service = new Apache_Solr_Service($service['host'], $service['port'], $service['path']);
  603. +
  604.                     $this->_readableServices[$id] = $service;
  605. +
  606.                 }
  607. +
  608.                 
  609. +
  610.                 $service->setCreateDocuments($this->_createDocuments);
  611. +
  612.                 $this->_currentReadService = $id;
  613. +
  614.             }
  615. +
  616.             else
  617. +
  618.             {
  619. +
  620.                 throw new Exception('No read services were available');
  621. +
  622.             }
  623. +
  624.         }
  625. +
  626.  
  627. +
  628.         return $this->_readableServices[$this->_currentReadService];
  629. +
  630.     }
  631. +
  632.  
  633. +
  634.     /**
  635. +
  636.      * Iterate through available write services and select the first with a ping
  637. +
  638.      * that satisfies configured timeout restrictions (or the default)
  639. +
  640.      *
  641. +
  642.      * @return Apache_Solr_Service 
  643. +
  644.      *
  645. +
  646.      * @throws Exception If there are no write services that meet requirements
  647. +
  648.      */
  649. +
  650.     protected function _selectWriteService($forceSelect = false)
  651. +
  652.     {
  653. +
  654.         if($this->_useBackoff)
  655. +
  656.         {
  657. +
  658.             return $this->_selectWriteServiceSafe($forceSelect);
  659. +
  660.         }        
  661. +
  662.         
  663. +
  664.         if (!$this->_currentWriteService || !isset($this->_writeableServices[$this->_currentWriteService]) || $forceSelect)
  665. +
  666.         {
  667. +
  668.             if ($this->_currentWriteService && isset($this->_writeableServices[$this->_currentWriteService]) && $forceSelect)
  669. +
  670.             {
  671. +
  672.                 // we probably had a communication error, ping the current read service, remove it if it times out
  673. +
  674.                 if ($this->_writeableServices[$this->_currentWriteService]->ping($this->_writePingTimeout) === false)
  675. +
  676.                 {
  677. +
  678.                     $this->removeWriteService($this->_currentWriteService);
  679. +
  680.                 }
  681. +
  682.             }
  683. +
  684.             
  685. +
  686.             if (count($this->_writeableServices))
  687. +
  688.             {
  689. +
  690.                 // select one of the read services at random
  691. +
  692.                 $ids = array_keys($this->_writeableServices);
  693. +
  694.                 
  695. +
  696.                 $id = $ids[rand(0, count($ids) - 1)];
  697. +
  698.                 $service = $this->_writeableServices[$id];
  699. +
  700.             
  701. +
  702.                 if (is_array($service))
  703. +
  704.                 {
  705. +
  706.                     //convert the array definition to a client object
  707. +
  708.                     $service = new Apache_Solr_Service($service['host'], $service['port'], $service['path']);
  709. +
  710.                     $this->_writeableServices[$id] = $service;
  711. +
  712.                 }
  713. +
  714.  
  715. +
  716.                 $this->_currentWriteService = $id;
  717. +
  718.             }
  719. +
  720.             else
  721. +
  722.             {
  723. +
  724.                 throw new Exception('No write services were available');
  725. +
  726.             }
  727. +
  728.         }
  729. +
  730.  
  731. +
  732.         return $this->_writeableServices[$this->_currentWriteService];
  733. +
  734.     }
  735. +
  736.     
  737. +
  738.     /**
  739. +
  740.      * Iterate through available write services and select the first with a ping
  741. +
  742.      * that satisfies configured timeout restrictions (or the default).  The
  743. +
  744.      * timeout period will increase until a connection is made or the limit is
  745. +
  746.      * reached.   This will allow for increased reliability with heavily loaded
  747. +
  748.      * server(s).
  749. +
  750.      *
  751. +
  752.      * @return Apache_Solr_Service 
  753. +
  754.      *
  755. +
  756.      * @throws Exception If there are no write services that meet requirements
  757. +
  758.      */    
  759. +
  760.     
  761. +
  762.     protected function _selectWriteServiceSafe($forceSelect = false)
  763. +
  764.     {        
  765. +
  766.         if (!$this->_currentWriteService || !isset($this->_writeableServices[$this->_currentWriteService]) || $forceSelect)
  767. +
  768.         {
  769. +
  770.             if (count($this->_writeableServices))
  771. +
  772.             {
  773. +
  774.                 $backoff = $this->_defaultBackoff;
  775. +
  776.                 
  777. +
  778.                 do {
  779. +
  780.                     // select one of the read services at random
  781. +
  782.                     $ids = array_keys($this->_writeableServices);
  783. +
  784.                     
  785. +
  786.                     $id = $ids[rand(0, count($ids) - 1)];
  787. +
  788.                     $service = $this->_writeableServices[$id];
  789. +
  790.                 
  791. +
  792.                     if (is_array($service))
  793. +
  794.                     {
  795. +
  796.                         //convert the array definition to a client object
  797. +
  798.                         $service = new Apache_Solr_Service($service['host'], $service['port'], $service['path']);
  799. +
  800.                         $this->_writeableServices[$id] = $service;
  801. +
  802.                     }
  803. +
  804.     
  805. +
  806.                     $this->_currentWriteService = $id;
  807. +
  808.                                         
  809. +
  810.                     $backoff *= $this->_backoffEscalation;
  811. +
  812.                     
  813. +
  814.                     if($backoff > $this->_backoffLimit)
  815. +
  816.                     {
  817. +
  818.                         throw new Exception('No write services were available.  All timeouts exceeded.');
  819. +
  820.                     }
  821. +
  822.                     
  823. +
  824.                 } while($this->_writeableServices[$this->_currentWriteService]->ping($backoff) === false);
  825. +
  826.             }
  827. +
  828.             else
  829. +
  830.             {
  831. +
  832.                 throw new Exception('No write services were available');
  833. +
  834.             }
  835. +
  836.         }
  837. +
  838.  
  839. +
  840.         return $this->_writeableServices[$this->_currentWriteService];
  841. +
  842.     }
  843. +
  844.  
  845. +
  846.     public function setCreateDocuments($createDocuments)
  847. +
  848.     {
  849. +
  850.         $this->_createDocuments = (bool) $createDocuments;
  851. +
  852.  
  853. +
  854.         if ($this->_currentReadService)
  855. +
  856.         {
  857. +
  858.             $service = $this->_selectReadService();
  859. +
  860.             $service->setCreateDocuments($createDocuments);
  861. +
  862.         }
  863. +
  864.     }
  865. +
  866.  
  867. +
  868.     public function getCreateDocuments()
  869. +
  870.     {
  871. +
  872.         return $this->_createDocuments;
  873. +
  874.     }
  875. +
  876.  
  877. +
  878.     /**
  879. +
  880.      * Raw Add Method. Takes a raw post body and sends it to the update service.  Post body
  881. +
  882.      * should be a complete and well formed "add" xml document.
  883. +
  884.      *
  885. +
  886.      * @param string $rawPost 
  887. +
  888.      * @return Apache_Solr_Response 
  889. +
  890.      *
  891. +
  892.      * @throws Exception If an error occurs during the service call
  893. +
  894.      */
  895. +
  896.     public function add($rawPost)
  897. +
  898.     {
  899. +
  900.         $service = $this->_selectWriteService();
  901. +
  902.  
  903. +
  904.         do
  905. +
  906.         {
  907. +
  908.             try
  909. +
  910.             {
  911. +
  912.                 return $service->add($rawPost);
  913. +
  914.             }
  915. +
  916.             catch (Exception $e)
  917. +
  918.             {
  919. +
  920.                 if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR
  921. +
  922.                 {
  923. +
  924.                     throw $e;
  925. +
  926.                 }
  927. +
  928.             }
  929. +
  930.  
  931. +
  932.             $service = $this->_selectWriteService(true);
  933. +
  934.         } while ($service);
  935. +
  936.         
  937. +
  938.         return false;
  939. +
  940.     }
  941. +
  942.  
  943. +
  944.     /**
  945. +
  946.      * Add a Solr Document to the index
  947. +
  948.      *
  949. +
  950.      * @param Apache_Solr_Document $document 
  951. +
  952.      * @param boolean $allowDups 
  953. +
  954.      * @param boolean $overwritePending 
  955. +
  956.      * @param boolean $overwriteCommitted 
  957. +
  958.      * @return Apache_Solr_Response 
  959. +
  960.      *
  961. +
  962.      * @throws Exception If an error occurs during the service call
  963. +
  964.      */
  965. +
  966.     public function addDocument(Apache_Solr_Document $document, $allowDups = false, $overwritePending = true, $overwriteCommitted = true)
  967. +
  968.     {
  969. +
  970.         $service = $this->_selectWriteService();
  971. +
  972.  
  973. +
  974.         do
  975. +
  976.         {
  977. +
  978.             try
  979. +
  980.             {
  981. +
  982.                 return $service->addDocument($document, $allowDups, $overwritePending, $overwriteCommitted);
  983. +
  984.             }
  985. +
  986.             catch (Exception $e)
  987. +
  988.             {
  989. +
  990.                 if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR
  991. +
  992.                 {
  993. +
  994.                     throw $e;
  995. +
  996.                 }
  997. +
  998.             }
  999. +
  1000.  
  1001. +
  1002.             $service = $this->_selectWriteService(true);
  1003. +
  1004.         } while ($service);
  1005. +
  1006.         
  1007. +
  1008.         return false;
  1009. +
  1010.     }
  1011. +
  1012.  
  1013. +
  1014.     /**
  1015. +
  1016.      * Add an array of Solr Documents to the index all at once
  1017. +
  1018.      *
  1019. +
  1020.      * @param array $documents Should be an array of Apache_Solr_Document instances
  1021. +
  1022.      * @param boolean $allowDups 
  1023. +
  1024.      * @param boolean $overwritePending 
  1025. +
  1026.      * @param boolean $overwriteCommitted 
  1027. +
  1028.      * @return Apache_Solr_Response 
  1029. +
  1030.      *
  1031. +
  1032.      * @throws Exception If an error occurs during the service call
  1033. +
  1034.      */
  1035. +
  1036.     public function addDocuments($documents, $allowDups = false, $overwritePending = true, $overwriteCommitted = true)
  1037. +
  1038.     {
  1039. +
  1040.         $service = $this->_selectWriteService();
  1041. +
  1042.  
  1043. +
  1044.         do
  1045. +
  1046.         {
  1047. +
  1048.             try
  1049. +
  1050.             {
  1051. +
  1052.                 return $service->addDocuments($documents, $allowDups, $overwritePending, $overwriteCommitted);
  1053. +
  1054.             }
  1055. +
  1056.             catch (Exception $e)
  1057. +
  1058.             {
  1059. +
  1060.                 if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR
  1061. +
  1062.                 {
  1063. +
  1064.                     throw $e;
  1065. +
  1066.                 }
  1067. +
  1068.             }
  1069. +
  1070.  
  1071. +
  1072.             $service = $this->_selectWriteService(true);
  1073. +
  1074.         } while ($service);
  1075. +
  1076.         
  1077. +
  1078.         return false;
  1079. +
  1080.     }
  1081. +
  1082.  
  1083. +
  1084.     /**
  1085. +
  1086.      * Send a commit command.  Will be synchronous unless both wait parameters are set
  1087. +
  1088.      * to false.
  1089. +
  1090.      *
  1091. +
  1092.      * @param boolean $waitFlush 
  1093. +
  1094.      * @param boolean $waitSearcher 
  1095. +
  1096.      * @return Apache_Solr_Response 
  1097. +
  1098.      *
  1099. +
  1100.      * @throws Exception If an error occurs during the service call
  1101. +
  1102.      */
  1103. +
  1104.     public function commit($optimize = true, $waitFlush = true, $waitSearcher = true, $timeout = 3600)
  1105. +
  1106.     {
  1107. +
  1108.         $service = $this->_selectWriteService();
  1109. +
  1110.  
  1111. +
  1112.         do
  1113. +
  1114.         {
  1115. +
  1116.             try
  1117. +
  1118.             {
  1119. +
  1120.                 return $service->commit($optimize, $waitFlush, $waitSearcher, $timeout);
  1121. +
  1122.             }
  1123. +
  1124.             catch (Exception $e)
  1125. +
  1126.             {
  1127. +
  1128.                 if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR
  1129. +
  1130.                 {
  1131. +
  1132.                     throw $e;
  1133. +
  1134.                 }
  1135. +
  1136.             }
  1137. +
  1138.  
  1139. +
  1140.             $service = $this->_selectWriteService(true);
  1141. +
  1142.         } while ($service);
  1143. +
  1144.         
  1145. +
  1146.         return false;
  1147. +
  1148.     }
  1149. +
  1150.  
  1151. +
  1152.     /**
  1153. +
  1154.      * Raw Delete Method. Takes a raw post body and sends it to the update service. Body should be
  1155. +
  1156.      * a complete and well formed "delete" xml document
  1157. +
  1158.      *
  1159. +
  1160.      * @param string $rawPost 
  1161. +
  1162.      * @return Apache_Solr_Response 
  1163. +
  1164.      *
  1165. +
  1166.      * @throws Exception If an error occurs during the service call
  1167. +
  1168.      */
  1169. +
  1170.     public function delete($rawPost)
  1171. +
  1172.     {
  1173. +
  1174.         $service = $this->_selectWriteService();
  1175. +
  1176.  
  1177. +
  1178.         do
  1179. +
  1180.         {
  1181. +
  1182.             try
  1183. +
  1184.             {
  1185. +
  1186.                 return $service->delete($rawPost);
  1187. +
  1188.             }
  1189. +
  1190.             catch (Exception $e)
  1191. +
  1192.             {
  1193. +
  1194.                 if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR
  1195. +
  1196.                 {
  1197. +
  1198.                     throw $e;
  1199. +
  1200.                 }
  1201. +
  1202.             }
  1203. +
  1204.  
  1205. +
  1206.             $service = $this->_selectWriteService(true);
  1207. +
  1208.         } while ($service);
  1209. +
  1210.         
  1211. +
  1212.         return false;
  1213. +
  1214.     }
  1215. +
  1216.  
  1217. +
  1218.     /**
  1219. +
  1220.      * Create a delete document based on document ID
  1221. +
  1222.      *
  1223. +
  1224.      * @param string $id 
  1225. +
  1226.      * @param boolean $fromPending 
  1227. +
  1228.      * @param boolean $fromCommitted 
  1229. +
  1230.      * @return Apache_Solr_Response 
  1231. +
  1232.      *
  1233. +
  1234.      * @throws Exception If an error occurs during the service call
  1235. +
  1236.      */
  1237. +
  1238.     public function deleteById($id, $fromPending = true, $fromCommitted = true)
  1239. +
  1240.     {
  1241. +
  1242.         $service = $this->_selectWriteService();
  1243. +
  1244.  
  1245. +
  1246.         do
  1247. +
  1248.         {
  1249. +
  1250.             try
  1251. +
  1252.             {
  1253. +
  1254.                 return $service->deleteById($id, $fromPending, $fromCommitted);
  1255. +
  1256.             }
  1257. +
  1258.             catch (Exception $e)
  1259. +
  1260.             {
  1261. +
  1262.                 if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR
  1263. +
  1264.                 {
  1265. +
  1266.                     throw $e;
  1267. +
  1268.                 }
  1269. +
  1270.             }
  1271. +
  1272.  
  1273. +
  1274.             $service = $this->_selectWriteService(true);
  1275. +
  1276.         } while ($service);
  1277. +
  1278.         
  1279. +
  1280.         return false;
  1281. +
  1282.     }
  1283. +
  1284.  
  1285. +
  1286.     /**
  1287. +
  1288.      * Create a delete document based on a query and submit it
  1289. +
  1290.      *
  1291. +
  1292.      * @param string $rawQuery 
  1293. +
  1294.      * @param boolean $fromPending 
  1295. +
  1296.      * @param boolean $fromCommitted 
  1297. +
  1298.      * @return Apache_Solr_Response 
  1299. +
  1300.      *
  1301. +
  1302.      * @throws Exception If an error occurs during the service call
  1303. +
  1304.      */
  1305. +
  1306.     public function deleteByQuery($rawQuery, $fromPending = true, $fromCommitted = true)
  1307. +
  1308.     {
  1309. +
  1310.         $service = $this->_selectWriteService();
  1311. +
  1312.  
  1313. +
  1314.         do
  1315. +
  1316.         {
  1317. +
  1318.             try
  1319. +
  1320.             {
  1321. +
  1322.                 return $service->deleteByQuery($rawQuery, $fromPending, $fromCommitted);
  1323. +
  1324.             }
  1325. +
  1326.             catch (Exception $e)
  1327. +
  1328.             {
  1329. +
  1330.                 if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR
  1331. +
  1332.                 {
  1333. +
  1334.                     throw $e;
  1335. +
  1336.                 }
  1337. +
  1338.             }
  1339. +
  1340.  
  1341. +
  1342.             $service = $this->_selectWriteService(true);
  1343. +
  1344.         } while ($service);
  1345. +
  1346.         
  1347. +
  1348.         return false;
  1349. +
  1350.     }
  1351. +
  1352.  
  1353. +
  1354.     /**
  1355. +
  1356.      * Send an optimize command.  Will be synchronous unless both wait parameters are set
  1357. +
  1358.      * to false.
  1359. +
  1360.      *
  1361. +
  1362.      * @param boolean $waitFlush 
  1363. +
  1364.      * @param boolean $waitSearcher 
  1365. +
  1366.      * @return Apache_Solr_Response 
  1367. +
  1368.      *
  1369. +
  1370.      * @throws Exception If an error occurs during the service call
  1371. +
  1372.      */
  1373. +
  1374.     public function optimize($waitFlush = true, $waitSearcher = true)
  1375. +
  1376.     {
  1377. +
  1378.         $service = $this->_selectWriteService();
  1379. +
  1380.  
  1381. +
  1382.         do
  1383. +
  1384.         {
  1385. +
  1386.             try
  1387. +
  1388.             {
  1389. +
  1390.                 return $service->optimize($waitFlush, $waitSearcher);
  1391. +
  1392.             }
  1393. +
  1394.             catch (Exception $e)
  1395. +
  1396.             {
  1397. +
  1398.                 if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR
  1399. +
  1400.                 {
  1401. +
  1402.                     throw $e;
  1403. +
  1404.                 }
  1405. +
  1406.             }
  1407. +
  1408.  
  1409. +
  1410.             $service = $this->_selectWriteService(true);
  1411. +
  1412.         } while ($service);
  1413. +
  1414.         
  1415. +
  1416.         return false;
  1417. +
  1418.     }
  1419. +
  1420.  
  1421. +
  1422.     /**
  1423. +
  1424.      * Simple Search interface
  1425. +
  1426.      *
  1427. +
  1428.      * @param string $query The raw query string
  1429. +
  1430.      * @param int $offset The starting offset for result documents
  1431. +
  1432.      * @param int $limit The maximum number of result documents to return
  1433. +
  1434.      * @param array $params key / value pairs for query parameters, use arrays for multivalued parameters
  1435. +
  1436.      * @return Apache_Solr_Response 
  1437. +
  1438.      *
  1439. +
  1440.      * @throws Exception If an error occurs during the service call
  1441. +
  1442.      */
  1443. +
  1444.     public function search($query, $offset = 0, $limit = 10, $params = array())
  1445. +
  1446.     {
  1447. +
  1448.         $service = $this->_selectReadService();
  1449. +
  1450.  
  1451. +
  1452.         do
  1453. +
  1454.         {
  1455. +
  1456.             try
  1457. +
  1458.             {
  1459. +
  1460.                 return $service->search($query, $offset, $limit, $params);
  1461. +
  1462.             }
  1463. +
  1464.             catch (Exception $e)
  1465. +
  1466.             {
  1467. +
  1468.                 if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR
  1469. +
  1470.                 {
  1471. +
  1472.                     throw $e;
  1473. +
  1474.                 }
  1475. +
  1476.             }
  1477. +
  1478.  
  1479. +
  1480.             $service = $this->_selectReadService(true);
  1481. +
  1482.         } while ($service);
  1483. +
  1484.         
  1485. +
  1486.         return false;
  1487. +
  1488.     }
  1489. +
  1490. }
  1491. +
+
+

+ Documentation generated on Tue, 02 Sep 2008 10:45:03 -0400 by phpDocumentor 1.4.0 +

+ + Index: sites/all/modules/apachesolr/SolrPhpClient/LICENSE =================================================================== RCS file: sites/all/modules/apachesolr/SolrPhpClient/LICENSE diff -N sites/all/modules/apachesolr/SolrPhpClient/LICENSE --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sites/all/modules/apachesolr/SolrPhpClient/LICENSE 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. Index: sites/all/modules/apachesolr/SolrPhpClient/Apache/Solr/Service/Balancer.php =================================================================== RCS file: sites/all/modules/apachesolr/SolrPhpClient/Apache/Solr/Service/Balancer.php diff -N sites/all/modules/apachesolr/SolrPhpClient/Apache/Solr/Service/Balancer.php --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sites/all/modules/apachesolr/SolrPhpClient/Apache/Solr/Service/Balancer.php 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,746 @@ +, Dan Wolfe + */ + +require_once('Apache/Solr/Service.php'); + +/** + * Reference Implementation for using multiple Solr services in a distribution. Functionality + * includes: + * routing of read / write operations + * failover (on selection) for multiple read servers + */ +class Apache_Solr_Service_Balancer +{ + protected $_createDocuments = true; + + protected $_readableServices = array(); + protected $_writeableServices = array(); + + protected $_currentReadService = null; + protected $_currentWriteService = null; + + protected $_readPingTimeout = 2; + protected $_writePingTimeout = 4; + + // Configuration for server selection backoff intervals + protected $_useBackoff = false; // Set to true to use more resillient write server selection + protected $_backoffLimit = 600; // 10 minute default maximum + protected $_backoffEscalation = 2.0; // Rate at which to increase backoff period + protected $_defaultBackoff = 2.0; // Default backoff interval + + /** + * Escape a value for special query characters such as ':', '(', ')', '*', '?', etc. + * + * NOTE: inside a phrase fewer characters need escaped, use {@link Apache_Solr_Service::escapePhrase()} instead + * + * @param string $value + * @return string + */ + static public function escape($value) + { + return Apache_Solr_Service::escape($value); + } + + /** + * Escape a value meant to be contained in a phrase for special query characters + * + * @param string $value + * @return string + */ + static public function escapePhrase($value) + { + return Apache_Solr_Service::escapePhrase($value); + } + + /** + * Convenience function for creating phrase syntax from a value + * + * @param string $value + * @return string + */ + static public function phrase($value) + { + return Apache_Solr_Service::phrase($value); + } + + /** + * Constructor. Takes arrays of read and write service instances or descriptions + * + * @param array $readableServices + * @param array $writeableServices + */ + public function __construct($readableServices = array(), $writeableServices = array()) + { + //setup readable services + foreach ($readableServices as $service) + { + $this->addReadService($service); + } + + //setup writeable services + foreach ($writeableServices as $service) + { + $this->addWriteService($service); + } + } + + public function setReadPingTimeout($timeout) + { + $this->_readPingTimeout = $timeout; + } + + public function setWritePingTimeout($timeout) + { + $this->_writePingTimeout = $timeout; + } + + public function setUseBackoff($enable) + { + $this->_useBackoff = $enable; + } + + /** + * Generates a service ID + * + * @param string $host + * @param integer $port + * @param string $path + * @return string + */ + protected function _getServiceId($host, $port, $path) + { + return $host . ':' . $port . $path; + } + + /** + * Adds a service instance or service descriptor (if it is already + * not added) + * + * @param mixed $service + * + * @throws Exception If service descriptor is not valid + */ + public function addReadService($service) + { + if ($service instanceof Apache_Solr_Service) + { + $id = $this->_getServiceId($service->getHost(), $service->getPort(), $service->getPath()); + + $this->_readableServices[$id] = $service; + } + else if (is_array($service)) + { + if (isset($service['host']) && isset($service['port']) && isset($service['path'])) + { + $id = $this->_getServiceId((string)$service['host'], (int)$service['port'], (string)$service['path']); + + $this->_readableServices[$id] = $service; + } + else + { + throw new Exception('A Readable Service description array does not have all required elements of host, port, and path'); + } + } + } + + /** + * Removes a service instance or descriptor from the available services + * + * @param mixed $service + * + * @throws Exception If service descriptor is not valid + */ + public function removeReadService($service) + { + $id = ''; + + if ($service instanceof Apache_Solr_Service) + { + $id = $this->_getServiceId($service->getHost(), $service->getPort(), $service->getPath()); + } + else if (is_array($service)) + { + if (isset($service['host']) && isset($service['port']) && isset($service['path'])) + { + $id = $this->_getServiceId((string)$service['host'], (int)$service['port'], (string)$service['path']); + } + else + { + throw new Exception('A Readable Service description array does not have all required elements of host, port, and path'); + } + } + else if (is_string($service)) + { + $id = $service; + } + + if ($id && isset($this->_readableServices[$id])) + { + unset($this->_readableServices[$id]); + } + } + + /** + * Adds a service instance or service descriptor (if it is already + * not added) + * + * @param mixed $service + * + * @throws Exception If service descriptor is not valid + */ + public function addWriteService($service) + { + if ($service instanceof Apache_Solr_Service) + { + $id = $this->_getServiceId($service->getHost(), $service->getPort(), $service->getPath()); + + $this->_writeableServices[$id] = $service; + } + else if (is_array($service)) + { + if (isset($service['host']) && isset($service['port']) && isset($service['path'])) + { + $id = $this->_getServiceId((string)$service['host'], (int)$service['port'], (string)$service['path']); + + $this->_writeableServices[$id] = $service; + } + else + { + throw new Exception('A Writeable Service description array does not have all required elements of host, port, and path'); + } + } + } + + /** + * Removes a service instance or descriptor from the available services + * + * @param mixed $service + * + * @throws Exception If service descriptor is not valid + */ + public function removeWriteService($service) + { + $id = ''; + + if ($service instanceof Apache_Solr_Service) + { + $id = $this->_getServiceId($service->getHost(), $service->getPort(), $service->getPath()); + } + else if (is_array($service)) + { + if (isset($service['host']) && isset($service['port']) && isset($service['path'])) + { + $id = $this->_getServiceId((string)$service['host'], (int)$service['port'], (string)$service['path']); + } + else + { + throw new Exception('A Readable Service description array does not have all required elements of host, port, and path'); + } + } + else if (is_string($service)) + { + $id = $service; + } + + if ($id && isset($this->_writeableServices[$id])) + { + unset($this->_writeableServices[$id]); + } + } + + /** + * Iterate through available read services and select the first with a ping + * that satisfies configured timeout restrictions (or the default) + * + * @return Apache_Solr_Service + * + * @throws Exception If there are no read services that meet requirements + */ + protected function _selectReadService($forceSelect = false) + { + if (!$this->_currentReadService || !isset($this->_readableServices[$this->_currentReadService]) || $forceSelect) + { + if ($this->_currentReadService && isset($this->_readableServices[$this->_currentReadService]) && $forceSelect) + { + // we probably had a communication error, ping the current read service, remove it if it times out + if ($this->_readableServices[$this->_currentReadService]->ping($this->_readPingTimeout) === false) + { + $this->removeReadService($this->_currentReadService); + } + } + + if (count($this->_readableServices)) + { + // select one of the read services at random + $ids = array_keys($this->_readableServices); + + $id = $ids[rand(0, count($ids) - 1)]; + $service = $this->_readableServices[$id]; + + if (is_array($service)) + { + //convert the array definition to a client object + $service = new Apache_Solr_Service($service['host'], $service['port'], $service['path']); + $this->_readableServices[$id] = $service; + } + + $service->setCreateDocuments($this->_createDocuments); + $this->_currentReadService = $id; + } + else + { + throw new Exception('No read services were available'); + } + } + + return $this->_readableServices[$this->_currentReadService]; + } + + /** + * Iterate through available write services and select the first with a ping + * that satisfies configured timeout restrictions (or the default) + * + * @return Apache_Solr_Service + * + * @throws Exception If there are no write services that meet requirements + */ + protected function _selectWriteService($forceSelect = false) + { + if($this->_useBackoff) + { + return $this->_selectWriteServiceSafe($forceSelect); + } + + if (!$this->_currentWriteService || !isset($this->_writeableServices[$this->_currentWriteService]) || $forceSelect) + { + if ($this->_currentWriteService && isset($this->_writeableServices[$this->_currentWriteService]) && $forceSelect) + { + // we probably had a communication error, ping the current read service, remove it if it times out + if ($this->_writeableServices[$this->_currentWriteService]->ping($this->_writePingTimeout) === false) + { + $this->removeWriteService($this->_currentWriteService); + } + } + + if (count($this->_writeableServices)) + { + // select one of the read services at random + $ids = array_keys($this->_writeableServices); + + $id = $ids[rand(0, count($ids) - 1)]; + $service = $this->_writeableServices[$id]; + + if (is_array($service)) + { + //convert the array definition to a client object + $service = new Apache_Solr_Service($service['host'], $service['port'], $service['path']); + $this->_writeableServices[$id] = $service; + } + + $this->_currentWriteService = $id; + } + else + { + throw new Exception('No write services were available'); + } + } + + return $this->_writeableServices[$this->_currentWriteService]; + } + + /** + * Iterate through available write services and select the first with a ping + * that satisfies configured timeout restrictions (or the default). The + * timeout period will increase until a connection is made or the limit is + * reached. This will allow for increased reliability with heavily loaded + * server(s). + * + * @return Apache_Solr_Service + * + * @throws Exception If there are no write services that meet requirements + */ + + protected function _selectWriteServiceSafe($forceSelect = false) + { + if (!$this->_currentWriteService || !isset($this->_writeableServices[$this->_currentWriteService]) || $forceSelect) + { + if (count($this->_writeableServices)) + { + $backoff = $this->_defaultBackoff; + + do { + // select one of the read services at random + $ids = array_keys($this->_writeableServices); + + $id = $ids[rand(0, count($ids) - 1)]; + $service = $this->_writeableServices[$id]; + + if (is_array($service)) + { + //convert the array definition to a client object + $service = new Apache_Solr_Service($service['host'], $service['port'], $service['path']); + $this->_writeableServices[$id] = $service; + } + + $this->_currentWriteService = $id; + + $backoff *= $this->_backoffEscalation; + + if($backoff > $this->_backoffLimit) + { + throw new Exception('No write services were available. All timeouts exceeded.'); + } + + } while($this->_writeableServices[$this->_currentWriteService]->ping($backoff) === false); + } + else + { + throw new Exception('No write services were available'); + } + } + + return $this->_writeableServices[$this->_currentWriteService]; + } + + public function setCreateDocuments($createDocuments) + { + $this->_createDocuments = (bool) $createDocuments; + + if ($this->_currentReadService) + { + $service = $this->_selectReadService(); + $service->setCreateDocuments($createDocuments); + } + } + + public function getCreateDocuments() + { + return $this->_createDocuments; + } + + /** + * Raw Add Method. Takes a raw post body and sends it to the update service. Post body + * should be a complete and well formed "add" xml document. + * + * @param string $rawPost + * @return Apache_Solr_Response + * + * @throws Exception If an error occurs during the service call + */ + public function add($rawPost) + { + $service = $this->_selectWriteService(); + + do + { + try + { + return $service->add($rawPost); + } + catch (Exception $e) + { + if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR + { + throw $e; + } + } + + $service = $this->_selectWriteService(true); + } while ($service); + + return false; + } + + /** + * Add a Solr Document to the index + * + * @param Apache_Solr_Document $document + * @param boolean $allowDups + * @param boolean $overwritePending + * @param boolean $overwriteCommitted + * @return Apache_Solr_Response + * + * @throws Exception If an error occurs during the service call + */ + public function addDocument(Apache_Solr_Document $document, $allowDups = false, $overwritePending = true, $overwriteCommitted = true) + { + $service = $this->_selectWriteService(); + + do + { + try + { + return $service->addDocument($document, $allowDups, $overwritePending, $overwriteCommitted); + } + catch (Exception $e) + { + if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR + { + throw $e; + } + } + + $service = $this->_selectWriteService(true); + } while ($service); + + return false; + } + + /** + * Add an array of Solr Documents to the index all at once + * + * @param array $documents Should be an array of Apache_Solr_Document instances + * @param boolean $allowDups + * @param boolean $overwritePending + * @param boolean $overwriteCommitted + * @return Apache_Solr_Response + * + * @throws Exception If an error occurs during the service call + */ + public function addDocuments($documents, $allowDups = false, $overwritePending = true, $overwriteCommitted = true) + { + $service = $this->_selectWriteService(); + + do + { + try + { + return $service->addDocuments($documents, $allowDups, $overwritePending, $overwriteCommitted); + } + catch (Exception $e) + { + if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR + { + throw $e; + } + } + + $service = $this->_selectWriteService(true); + } while ($service); + + return false; + } + + /** + * Send a commit command. Will be synchronous unless both wait parameters are set + * to false. + * + * @param boolean $waitFlush + * @param boolean $waitSearcher + * @return Apache_Solr_Response + * + * @throws Exception If an error occurs during the service call + */ + public function commit($optimize = true, $waitFlush = true, $waitSearcher = true, $timeout = 3600) + { + $service = $this->_selectWriteService(); + + do + { + try + { + return $service->commit($optimize, $waitFlush, $waitSearcher, $timeout); + } + catch (Exception $e) + { + if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR + { + throw $e; + } + } + + $service = $this->_selectWriteService(true); + } while ($service); + + return false; + } + + /** + * Raw Delete Method. Takes a raw post body and sends it to the update service. Body should be + * a complete and well formed "delete" xml document + * + * @param string $rawPost + * @return Apache_Solr_Response + * + * @throws Exception If an error occurs during the service call + */ + public function delete($rawPost) + { + $service = $this->_selectWriteService(); + + do + { + try + { + return $service->delete($rawPost); + } + catch (Exception $e) + { + if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR + { + throw $e; + } + } + + $service = $this->_selectWriteService(true); + } while ($service); + + return false; + } + + /** + * Create a delete document based on document ID + * + * @param string $id + * @param boolean $fromPending + * @param boolean $fromCommitted + * @return Apache_Solr_Response + * + * @throws Exception If an error occurs during the service call + */ + public function deleteById($id, $fromPending = true, $fromCommitted = true) + { + $service = $this->_selectWriteService(); + + do + { + try + { + return $service->deleteById($id, $fromPending, $fromCommitted); + } + catch (Exception $e) + { + if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR + { + throw $e; + } + } + + $service = $this->_selectWriteService(true); + } while ($service); + + return false; + } + + /** + * Create a delete document based on a query and submit it + * + * @param string $rawQuery + * @param boolean $fromPending + * @param boolean $fromCommitted + * @return Apache_Solr_Response + * + * @throws Exception If an error occurs during the service call + */ + public function deleteByQuery($rawQuery, $fromPending = true, $fromCommitted = true) + { + $service = $this->_selectWriteService(); + + do + { + try + { + return $service->deleteByQuery($rawQuery, $fromPending, $fromCommitted); + } + catch (Exception $e) + { + if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR + { + throw $e; + } + } + + $service = $this->_selectWriteService(true); + } while ($service); + + return false; + } + + /** + * Send an optimize command. Will be synchronous unless both wait parameters are set + * to false. + * + * @param boolean $waitFlush + * @param boolean $waitSearcher + * @return Apache_Solr_Response + * + * @throws Exception If an error occurs during the service call + */ + public function optimize($waitFlush = true, $waitSearcher = true) + { + $service = $this->_selectWriteService(); + + do + { + try + { + return $service->optimize($waitFlush, $waitSearcher); + } + catch (Exception $e) + { + if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR + { + throw $e; + } + } + + $service = $this->_selectWriteService(true); + } while ($service); + + return false; + } + + /** + * Simple Search interface + * + * @param string $query The raw query string + * @param int $offset The starting offset for result documents + * @param int $limit The maximum number of result documents to return + * @param array $params key / value pairs for query parameters, use arrays for multivalued parameters + * @return Apache_Solr_Response + * + * @throws Exception If an error occurs during the service call + */ + public function search($query, $offset = 0, $limit = 10, $params = array()) + { + $service = $this->_selectReadService(); + + do + { + try + { + return $service->search($query, $offset, $limit, $params); + } + catch (Exception $e) + { + if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR + { + throw $e; + } + } + + $service = $this->_selectReadService(true); + } while ($service); + + return false; + } +} Index: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_Service.html =================================================================== RCS file: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_Service.html diff -N sites/all/modules/apachesolr/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_Service.html --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sites/all/modules/apachesolr/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_Service.html 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,1935 @@ + + + + + + Docs For Class Apache_Solr_Service + + + + +
+ +

Class Apache_Solr_Service

+ + +
+
Description
+ +
+ +

Starting point for the Solr API. Represents a Solr server resource and has methods for pinging, adding, deleting, committing, optimizing and searching.

+

Example Usage:

  1.  ...
  2. +
  3.  $solr = new Apache_Solr_Service(); //or explicitly new Apache_Solr_Service('localhost', 8180, '/solr')
  4. +
  5.  
  6. +
  7.  if ($solr->ping())
  8. +
  9.  {
  10. +
  11.          $solr->deleteByQuery('*:*'); //deletes ALL documents - be careful :)
  12. +
  13.  
  14. +
  15.          $document = new Apache_Solr_Document();
  16. +
  17.          $document->id = uniqid(); //or something else suitably unique
  18. +
  19.  
  20. +
  21.          $document->title = 'Some Title';
  22. +
  23.          $document->content = 'Some content for this wonderful document. Blah blah blah.';
  24. +
  25.  
  26. +
  27.          $solr->addDocument($document);     //if you're going to be adding documents in bulk using addDocuments
  28. +
  29.                                          //with an array of documents is faster
  30. +
  31.  
  32. +
  33.          $solr->commit(); //commit to see the deletes and the document
  34. +
  35.          $solr->optimize(); //merges multiple segments into one
  36. +
  37.  
  38. +
  39.          //and the one we all care about, search!
  40. +
  41.          //any other common or custom parameters to the request handler can go in the
  42. +
  43.          //optional 4th array argument.
  44. +
  45.          $solr->search('content:blah', 0, 10, array('sort' => 'timestamp desc'));
  46. +
  47.  }
  48. +
  49.  ...
  50. +

+
    +
  • todo: Investigate using other HTTP clients other than file_get_contents built-in handler. Could provide performance improvements when dealing with multiple requests by using HTTP's keep alive functionality
  • +
+

+ Located in /Service.php (line 62) +

+ + +

+	
+			
+
+ + + +
+
Class Constant Summary
+ +
+
+
+  + NAMED_LIST_FLAT = 'flat' + +
+
+  + NAMED_LIST_MAP = 'map' + +
+
+  + PING_SERVLET = 'admin/ping' + +
+
+  + SEARCH_SERVLET = 'select' + +
+
+  + SOLR_VERSION = '1.2' + +
+
+  + SOLR_WRITER = 'json' + +
+
+  + THREADS_SERVLET = 'admin/threads' + +
+
+  + UPDATE_SERVLET = 'update' + +
+
+
+
+ + +
+
Variable Summary
+ +
+
+ +
+ boolean + $_createDocuments +
+
+ string + $_host +
+
+ string + $_namedListTreatment +
+
+ mixed + $_path +
+
+ mixed + $_port +
+
+ resource + $_postContext +
+
+ string + $_queryDelimiter +
+ +
+ mixed + $_searchUrl +
+
+ mixed + $_threadsUrl +
+
+ string + $_updateUrl +
+
+ boolean + $_urlsInited +
+
+
+
+ + +
+
Method Summary
+ +
+
+ +
+ static string + escape + (string $value) +
+ +
+ static string + escapePhrase + (string $value) +
+ +
+ static string + phrase + (string $value) +
+ +
+ Apache_Solr_Response + add + (string $rawPost) +
+ +
+ Apache_Solr_Response + addDocument + (Apache_Solr_Document $document, [boolean $allowDups = false], [boolean $overwritePending = true], [boolean $overwriteCommitted = true]) +
+ +
+ Apache_Solr_Response + addDocuments + (array $documents, [boolean $allowDups = false], [boolean $overwritePending = true], [boolean $overwriteCommitted = true]) +
+ +
+ Apache_Solr_Response + commit + ([boolean $optimize = true], [boolean $waitFlush = true], [boolean $waitSearcher = true], [float $timeout = 3600]) +
+ +
+ Apache_Solr_Response + delete + (string $rawPost) +
+ +
+ Apache_Solr_Response + deleteById + (string $id, [boolean $fromPending = true], [boolean $fromCommitted = true]) +
+ +
+ Apache_Solr_Response + deleteByQuery + (string $rawQuery, [boolean $fromPending = true], [boolean $fromCommitted = true]) +
+ +
+ boolean + getCollapseSingleValueArrays + () +
+ +
+ boolean + getCreateDocuments + () +
+ +
+ string + getHost + () +
+ +
+ string + getNamedListTreatment + () +
+ +
+ string + getPath + () +
+ +
+ integer + getPort + () +
+ +
+ Apache_Solr_Service + __construct + ([string $host = 'localhost'], [string $port = 8180], [string $path = '/solr/']) +
+ +
+ Apache_Solr_Response + optimize + ([boolean $waitFlush = true], [boolean $waitSearcher = true], [float $timeout = 3600]) +
+ +
+ float + ping + ([float $timeout = 2]) +
+ +
+ Apache_Solr_Response + search + (string $query, [int $offset = 0], [int $limit = 10], [array $params = array()]) +
+ +
+ void + setCollapseSingleValueArrays + (boolean $collapseSingleValueArrays) +
+ +
+ void + setCreateDocuments + (unknown_type $createDocuments) +
+ +
+ void + setHost + (string $host) +
+ +
+ void + setNamedListTreatmet + (string $namedListTreatment) +
+ +
+ void + setPath + (string $path) +
+ +
+ void + setPort + (integer $port) +
+ +
+ void + setQueryDelimiter + (string $queryDelimiter) +
+ +
+ void + setQueryStringDelimiter + (string $queryStringDelimiter) +
+ + + +
+ string + _constructUrl + (string $servlet, [ $params = array()]) +
+ +
+ string + _documentToXmlFragment + (Apache_Solr_Document $document) +
+ +
+ void + _initUrls + () +
+ +
+ Apache_Solr_Response + _sendRawGet + (string $url, [float $timeout = FALSE]) +
+ +
+ Apache_Solr_Response + _sendRawPost + (string $url, string $rawPost, [float $timeout = FALSE], [string $contentType = 'text/xml; charset=UTF-8']) +
+
+
+
+ + +
+
Variables
+ +
+ + +
+ +
+ + boolean + $_collapseSingleValueArrays + = true (line 111) + +
+ + +

Whether Apache_Solr_Response objects should have multivalue fields with only a single value collapsed to appear as a single value would.

+
    +
  • access: protected
  • +
+ + + + + +
+ +
+ +
+ + boolean + $_createDocuments + = true (line 103) + +
+ + +

Whether Apache_Solr_Response objects should create Apache_Solr_Documents in the returned parsed data

+
    +
  • access: protected
  • +
+ + + + + +
+ +
+ +
+ + string + $_host + (line 95) + +
+ + +

Server identification strings

+
    +
  • access: protected
  • +
+ + + + + +
+ +
+ +
+ + string + $_namedListTreatment + = self::NAMED_LIST_MAP (line 119) + +
+ + +

How NamedLists should be formatted in the output. This specifically effects facet counts. Valid values are Apache_Solr_Service::NAMED_LIST_MAP (default) or Apache_Solr_Service::NAMED_LIST_FLAT.

+
    +
  • access: protected
  • +
+ + + + + +
+ +
+ +
+ + mixed + $_path + (line 95) + +
+ + +
    +
  • access: protected
  • +
+ + + + + +
+ +
+ +
+ + mixed + $_port + (line 95) + +
+ + +
    +
  • access: protected
  • +
+ + + + + +
+ +
+ +
+ + resource + $_postContext + (line 148) + +
+ + +

Stream context for posting

+
    +
  • access: protected
  • +
+ + + + + +
+ +
+ +
+ + string + $_queryDelimiter + = '?' (line 127) + +
+ + +

Query delimiters. Someone might want to be able to change these (to use &amp; instead of & for example), so I've provided them.

+
    +
  • access: protected
  • +
+ + + + + +
+ +
+ +
+ + mixed + $_queryStringDelimiter + = '&' (line 127) + +
+ + +
    +
  • access: protected
  • +
+ + + + + +
+ +
+ +
+ + mixed + $_searchUrl + (line 134) + +
+ + +
    +
  • access: protected
  • +
+ + + + + +
+ +
+ +
+ + mixed + $_threadsUrl + (line 134) + +
+ + +
    +
  • access: protected
  • +
+ + + + + +
+ +
+ +
+ + string + $_updateUrl + (line 134) + +
+ + +

Constructed servlet full path URLs

+
    +
  • access: protected
  • +
+ + + + + +
+ +
+ +
+ + boolean + $_urlsInited + = false (line 141) + +
+ + +

Keep track of whether our URLs have been constructed

+
    +
  • access: protected
  • +
+ + + + + +
+ + +
+
+ + +
+
Methods
+ +
+ + +
+ +
+ static escape (line 158) +
+ + +

Escape a value for special query characters such as ':', '(', ')', '*', '?', etc.

+

NOTE: inside a phrase fewer characters need escaped, use Apache_Solr_Service::escapePhrase() instead

+
    +
  • access: public
  • +
+ +
+ static string + + escape + + (string $value) +
+ +
    +
  • + string + $value
  • +
+ + +
+ +
+ +
+ static escapePhrase (line 173) +
+ + +

Escape a value meant to be contained in a phrase for special query characters

+
    +
  • access: public
  • +
+ +
+ static string + + escapePhrase + + (string $value) +
+ +
    +
  • + string + $value
  • +
+ + +
+ +
+ +
+ static phrase (line 187) +
+ + +

Convenience function for creating phrase syntax from a value

+
    +
  • access: public
  • +
+ +
+ static string + + phrase + + (string $value) +
+ +
    +
  • + string + $value
  • +
+ + +
+ +
+ +
+ add (line 643) +
+ + +

Raw Add Method. Takes a raw post body and sends it to the update service. Post body should be a complete and well formed "add" xml document.

+
    +
  • throws: Exception If an error occurs during the service call
  • +
  • access: public
  • +
+ +
+ Apache_Solr_Response + + add + + (string $rawPost) +
+ +
    +
  • + string + $rawPost
  • +
+ + +
+ +
+ +
+ addDocument (line 659) +
+ + +

Add a Solr Document to the index

+
    +
  • throws: Exception If an error occurs during the service call
  • +
  • access: public
  • +
+ +
+ Apache_Solr_Response + + addDocument + + (Apache_Solr_Document $document, [boolean $allowDups = false], [boolean $overwritePending = true], [boolean $overwriteCommitted = true]) +
+ +
    +
  • + Apache_Solr_Document + $document
  • +
  • + boolean + $allowDups
  • +
  • + boolean + $overwritePending
  • +
  • + boolean + $overwriteCommitted
  • +
+ + +
+ +
+ +
+ addDocuments (line 683) +
+ + +

Add an array of Solr Documents to the index all at once

+
    +
  • throws: Exception If an error occurs during the service call
  • +
  • access: public
  • +
+ +
+ Apache_Solr_Response + + addDocuments + + (array $documents, [boolean $allowDups = false], [boolean $overwritePending = true], [boolean $overwriteCommitted = true]) +
+ +
    +
  • + array + $documents: Should be an array of Apache_Solr_Document instances
  • +
  • + boolean + $allowDups
  • +
  • + boolean + $overwritePending
  • +
  • + boolean + $overwriteCommitted
  • +
+ + +
+ +
+ +
+ commit (line 750) +
+ + +

Send a commit command. Will be synchronous unless both wait parameters are set to false.

+
    +
  • throws: Exception If an error occurs during the service call
  • +
  • access: public
  • +
+ +
+ Apache_Solr_Response + + commit + + ([boolean $optimize = true], [boolean $waitFlush = true], [boolean $waitSearcher = true], [float $timeout = 3600]) +
+ +
    +
  • + boolean + $optimize: Defaults to true
  • +
  • + boolean + $waitFlush: Defaults to true
  • +
  • + boolean + $waitSearcher: Defaults to true
  • +
  • + float + $timeout: Maximum expected duration (in seconds) of the commit operation on the server (otherwise, will throw a communication exception). Defaults to 1 hour
  • +
+ + +
+ +
+ +
+ delete (line 770) +
+ + +

Raw Delete Method. Takes a raw post body and sends it to the update service. Body should be a complete and well formed "delete" xml document

+
    +
  • throws: Exception If an error occurs during the service call
  • +
  • access: public
  • +
+ +
+ Apache_Solr_Response + + delete + + (string $rawPost) +
+ +
    +
  • + string + $rawPost: Expected to be utf-8 encoded xml document
  • +
+ + +
+ +
+ +
+ deleteById (line 785) +
+ + +

Create a delete document based on document ID

+
    +
  • throws: Exception If an error occurs during the service call
  • +
  • access: public
  • +
+ +
+ Apache_Solr_Response + + deleteById + + (string $id, [boolean $fromPending = true], [boolean $fromCommitted = true]) +
+ +
    +
  • + string + $id: Expected to be utf-8 encoded
  • +
  • + boolean + $fromPending
  • +
  • + boolean + $fromCommitted
  • +
+ + +
+ +
+ +
+ deleteByQuery (line 808) +
+ + +

Create a delete document based on a query and submit it

+
    +
  • throws: Exception If an error occurs during the service call
  • +
  • access: public
  • +
+ +
+ Apache_Solr_Response + + deleteByQuery + + (string $rawQuery, [boolean $fromPending = true], [boolean $fromCommitted = true]) +
+ +
    +
  • + string + $rawQuery: Expected to be utf-8 encoded
  • +
  • + boolean + $fromPending
  • +
  • + boolean + $fromCommitted
  • +
+ + +
+ +
+ +
+ getCollapseSingleValueArrays (line 450) +
+ + +

Get the current state of the collapse single value arrays flag.

+
    +
  • access: public
  • +
+ +
+ boolean + + getCollapseSingleValueArrays + + () +
+ + + +
+ +
+ +
+ getCreateDocuments (line 430) +
+ + +

Get the current state of teh create documents flag.

+
    +
  • access: public
  • +
+ +
+ boolean + + getCreateDocuments + + () +
+ + + +
+ +
+ +
+ getHost (line 324) +
+ + +

Returns the set host

+
    +
  • access: public
  • +
+ +
+ string + + getHost + + () +
+ + + +
+ +
+ +
+ getNamedListTreatment (line 484) +
+ + +

Get the current setting for named list treatment.

+
    +
  • access: public
  • +
+ +
+ string + + getNamedListTreatment + + () +
+ + + +
+ +
+ +
+ getPath (line 392) +
+ + +

Get the set path.

+
    +
  • access: public
  • +
+ +
+ string + + getPath + + () +
+ + + +
+ +
+ +
+ getPort (line 357) +
+ + +

Get the set port

+
    +
  • access: public
  • +
+ +
+ integer + + getPort + + () +
+ + + +
+ +
+ +
+ Constructor __construct (line 200) +
+ + +

Constructor. All parameters are optional and will take on default values if not specified.

+
    +
  • access: public
  • +
+ +
+ Apache_Solr_Service + + __construct + + ([string $host = 'localhost'], [string $port = 8180], [string $path = '/solr/']) +
+ +
    +
  • + string + $host
  • +
  • + string + $port
  • +
  • + string + $path
  • +
+ + +
+ +
+ +
+ optimize (line 832) +
+ + +

Send an optimize command. Will be synchronous unless both wait parameters are set to false.

+
    +
  • throws: Exception If an error occurs during the service call
  • +
  • access: public
  • +
+ +
+ Apache_Solr_Response + + optimize + + ([boolean $waitFlush = true], [boolean $waitSearcher = true], [float $timeout = 3600]) +
+ +
    +
  • + boolean + $waitFlush
  • +
  • + boolean + $waitSearcher
  • +
  • + float + $timeout: Maximum expected duration of the commit operation on the server (otherwise, will throw a communication exception)
  • +
+ + +
+ +
+ +
+ ping (line 519) +
+ + +

Call the /admin/ping servlet, can be used to quickly tell if a connection to the server is able to be made.

+
    +
  • return: Actual time taken to ping the server, FALSE if timeout occurs
  • +
  • access: public
  • +
+ +
+ float + + ping + + ([float $timeout = 2]) +
+ +
    +
  • + float + $timeout: maximum time to wait for ping in seconds, -1 for unlimited (default is 2)
  • +
+ + +
+ +
+ +
+ search (line 853) +
+ + +

Simple Search interface

+
    +
  • throws: Exception If an error occurs during the service call
  • +
  • access: public
  • +
+ +
+ Apache_Solr_Response + + search + + (string $query, [int $offset = 0], [int $limit = 10], [array $params = array()]) +
+ +
    +
  • + string + $query: The raw query string
  • +
  • + int + $offset: The starting offset for result documents
  • +
  • + int + $limit: The maximum number of result documents to return
  • +
  • + array + $params: key / value pairs for other query parameters (see Solr documentation), use arrays for parameter keys used more than once (e.g. facet.field)
  • +
+ + +
+ +
+ +
+ setCollapseSingleValueArrays (line 440) +
+ + +

Set the collapse single value arrays flag.

+
    +
  • access: public
  • +
+ +
+ void + + setCollapseSingleValueArrays + + (boolean $collapseSingleValueArrays) +
+ +
    +
  • + boolean + $collapseSingleValueArrays
  • +
+ + +
+ +
+ +
+ setCreateDocuments (line 420) +
+ + +

Set the create documents flag. This determines whether Apache_Solr_Response objects will parse the response and create Apache_Solr_Document instances in place.

+
    +
  • access: public
  • +
+ +
+ void + + setCreateDocuments + + (unknown_type $createDocuments) +
+ +
    +
  • + unknown_type + $createDocuments
  • +
+ + +
+ +
+ +
+ setHost (line 334) +
+ + +

Set the host used. If empty will fallback to constants

+
    +
  • access: public
  • +
+ +
+ void + + setHost + + (string $host) +
+ +
    +
  • + string + $host
  • +
+ + +
+ +
+ +
+ setNamedListTreatmet (line 462) +
+ + +

Set how NamedLists should be formatted in the response data. This mainly effects the facet counts format.

+
    +
  • throws: Exception If invalid option is set
  • +
  • access: public
  • +
+ +
+ void + + setNamedListTreatmet + + (string $namedListTreatment) +
+ +
    +
  • + string + $namedListTreatment
  • +
+ + +
+ +
+ +
+ setPath (line 402) +
+ + +

Set the path used. If empty will fallback to constants

+
    +
  • access: public
  • +
+ +
+ void + + setPath + + (string $path) +
+ +
    +
  • + string + $path
  • +
+ + +
+ +
+ +
+ setPort (line 367) +
+ + +

Set the port used. If empty will fallback to constants

+
    +
  • access: public
  • +
+ +
+ void + + setPort + + (integer $port) +
+ +
    +
  • + integer + $port
  • +
+ + +
+ +
+ +
+ setQueryDelimiter (line 496) +
+ + +

Set the string used to separate the path form the query string.

+

Defaulted to '?'

+
    +
  • access: public
  • +
+ +
+ void + + setQueryDelimiter + + (string $queryDelimiter) +
+ +
    +
  • + string + $queryDelimiter
  • +
+ + +
+ +
+ +
+ setQueryStringDelimiter (line 507) +
+ + +

Set the string used to separate the parameters in thequery string Defaulted to '&'

+
    +
  • access: public
  • +
+ +
+ void + + setQueryStringDelimiter + + (string $queryStringDelimiter) +
+ +
    +
  • + string + $queryStringDelimiter
  • +
+ + +
+ +
+ +
+ threads (line 629) +
+ + +

Call the /admin/threads servlet and retrieve information about all threads in the Solr servlet's thread group. Useful for diagnostics.

+
    +
  • throws: Exception If an error occurs during the service call
  • +
  • access: public
  • +
+ +
+ Apache_Solr_Response + + threads + + () +
+ + + +
+ +
+ +
+ _constructUrl (line 225) +
+ + +

Return a valid http URL given this server's host, port and path and a provided servlet name

+
    +
  • access: protected
  • +
+ +
+ string + + _constructUrl + + (string $servlet, [ $params = array()]) +
+ +
    +
  • + string + $servlet
  • +
  • + + $params
  • +
+ + +
+ +
+ +
+ _documentToXmlFragment (line 709) +
+ + +

Create an XML fragment from a Apache_Solr_Document instance appropriate for use inside a Solr add call

+
    +
  • access: protected
  • +
+ +
+ string + + _documentToXmlFragment + + (Apache_Solr_Document $document) +
+ + + + +
+ +
+ +
+ _initUrls (line 250) +
+ + +

Construct the Full URLs for the three servlets we reference

+
    +
  • access: protected
  • +
+ +
+ void + + _initUrls + + () +
+ + + +
+ +
+ +
+ _sendRawGet (line 270) +
+ + +

Central method for making a get operation against this Solr Server

+
    +
  • todo: implement timeout ability
  • +
  • throws: Exception If a non 200 response status is returned
  • +
  • access: protected
  • +
+ +
+ Apache_Solr_Response + + _sendRawGet + + (string $url, [float $timeout = FALSE]) +
+ +
    +
  • + string + $url
  • +
  • + float + $timeout: Read timeout in seconds
  • +
+ + +
+ +
+ +
+ _sendRawPost (line 294) +
+ + +

Central method for making a post operation against this Solr Server

+
    +
  • throws: Exception If a non 200 response status is returned
  • +
  • access: protected
  • +
+ +
+ Apache_Solr_Response + + _sendRawPost + + (string $url, string $rawPost, [float $timeout = FALSE], [string $contentType = 'text/xml; charset=UTF-8']) +
+ +
    +
  • + string + $url
  • +
  • + string + $rawPost
  • +
  • + float + $timeout: Read timeout in seconds
  • +
  • + string + $contentType
  • +
+ + +
+ +
+
+ + +
+
Class Constants
+ +
+ +
+ +
+ + + NAMED_LIST_FLAT + = 'flat' + (line 79) + +
+ + +

NamedList Treatment constants

+ + +
+ +
+ +
+ + + NAMED_LIST_MAP + = 'map' + (line 80) + +
+ + + + +
+ +
+ +
+ + + PING_SERVLET + = 'admin/ping' + (line 85) + +
+ + +

Servlet mappings

+ + +
+ +
+ +
+ + + SEARCH_SERVLET + = 'select' + (line 87) + +
+ + + + +
+ +
+ +
+ + + SOLR_VERSION + = '1.2' + (line 67) + +
+ + +

Response version we support

+ + +
+ +
+ +
+ + + SOLR_WRITER + = 'json' + (line 74) + +
+ + +

Response writer we support

+
    +
  • todo: Solr 1.3 release may change this to SerializedPHP or PHP implementation
  • +
+ + +
+ +
+ +
+ + + THREADS_SERVLET + = 'admin/threads' + (line 88) + +
+ + + + +
+ +
+ +
+ + + UPDATE_SERVLET + = 'update' + (line 86) + +
+ + + + +
+ + +
+
+ +

+ Documentation generated on Tue, 02 Sep 2008 10:45:05 -0400 by phpDocumentor 1.4.0 +

+
+ Index: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_Document.php.html =================================================================== RCS file: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_Document.php.html diff -N sites/all/modules/apachesolr/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_Document.php.html --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sites/all/modules/apachesolr/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_Document.php.html 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,220 @@ + + + + + + File Source for Document.php + + + + + +

Source for file Document.php

+

Documentation is available at Document.php

+
+
  1. <?php
  2. +
  3. /**
  4. +
  5.  * @copyright Copyright 2007 Conduit Internet Technologies, Inc. (http://conduit-it.com)
  6. +
  7.  * @license Apache Licence, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
  8. +
  9.  *
  10. +
  11.  *  Licensed under the Apache License, Version 2.0 (the "License");
  12. +
  13.  *  you may not use this file except in compliance with the License.
  14. +
  15.  *  You may obtain a copy of the License at
  16. +
  17.  *
  18. +
  19.  *      http://www.apache.org/licenses/LICENSE-2.0
  20. +
  21.  *
  22. +
  23.  *  Unless required by applicable law or agreed to in writing, software
  24. +
  25.  *  distributed under the License is distributed on an "AS IS" BASIS,
  26. +
  27.  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  28. +
  29.  *  See the License for the specific language governing permissions and
  30. +
  31.  *  limitations under the License.
  32. +
  33.  *
  34. +
  35.  * @package Apache
  36. +
  37.  * @subpackage Solr
  38. +
  39.  * @author Donovan Jimenez <djimenez@conduit-it.com>
  40. +
  41.  */
  42. +
  43.  
  44. +
  45. /**
  46. +
  47.  * Holds Key / Value pairs that represent a Solr Document. Field values can be accessed
  48. +
  49.  * by direct dereferencing such as:
  50. +
  51.  * <code>
  52. +
  53.  * ...
  54. +
  55.  * $document->title = 'Something';
  56. +
  57.  * echo $document->title;
  58. +
  59.  * ...
  60. +
  61.  * </code>
  62. +
  63.  *
  64. +
  65.  * Additionally, the field values can be iterated with foreach
  66. +
  67.  *
  68. +
  69.  * <code>
  70. +
  71.  * foreach ($document as $key => $value)
  72. +
  73.  * {
  74. +
  75.  * ...
  76. +
  77.  * }
  78. +
  79.  * </code>
  80. +
  81.  */
  82. +
  83. class Apache_Solr_Document implements Iterator
  84. +
  85. {
  86. +
  87.     protected $_fields = array();
  88. +
  89.  
  90. +
  91.     /**
  92. +
  93.      * Magic get for field values
  94. +
  95.      *
  96. +
  97.      * @param string $key 
  98. +
  99.      * @return mixed 
  100. +
  101.      */
  102. +
  103.     public function __get($key)
  104. +
  105.     {
  106. +
  107.         return $this->_fields[$key];
  108. +
  109.     }
  110. +
  111.  
  112. +
  113.     /**
  114. +
  115.      * Magic set for field values. Multi-valued fields should be set as arrays
  116. +
  117.      * or instead use the setMultiValue(...) function which will automatically
  118. +
  119.      * make sure the field is an array.
  120. +
  121.      *
  122. +
  123.      * @param string $key 
  124. +
  125.      * @param mixed $value 
  126. +
  127.      */
  128. +
  129.     public function __set($key, $value)
  130. +
  131.     {
  132. +
  133.         $this->_fields[$key] = $value;
  134. +
  135.     }
  136. +
  137.  
  138. +
  139.     /**
  140. +
  141.      * Magic isset for fields values.  Do no call directly. Allows usage:
  142. +
  143.      *
  144. +
  145.      * <code>
  146. +
  147.      * isset($document->some_field);
  148. +
  149.      * </code>
  150. +
  151.      *
  152. +
  153.      * @param string $key 
  154. +
  155.      * @return boolean 
  156. +
  157.      */
  158. +
  159.     public function __isset($key)
  160. +
  161.     {
  162. +
  163.         return isset($this->_fields[$key]);
  164. +
  165.     }
  166. +
  167.  
  168. +
  169.     /**
  170. +
  171.      * Magic unset for field values. Do no call directly. Allows usage:
  172. +
  173.      *
  174. +
  175.      * <code>
  176. +
  177.      * unset($document->some_field);
  178. +
  179.      * </code>
  180. +
  181.      *
  182. +
  183.      * @param string $key 
  184. +
  185.      */
  186. +
  187.     public function __unset($key)
  188. +
  189.     {
  190. +
  191.         unset($this->_fields[$key]);
  192. +
  193.     }
  194. +
  195.  
  196. +
  197.     /**
  198. +
  199.      * Handle the array manipulation for a multi-valued field
  200. +
  201.      *
  202. +
  203.      * @param string $key 
  204. +
  205.      * @param string $value 
  206. +
  207.      */
  208. +
  209.     public function setMultiValue($key, $value)
  210. +
  211.     {
  212. +
  213.         if (!isset($this->_fields[$key]))
  214. +
  215.         {
  216. +
  217.             $this->_fields[$key] = array();
  218. +
  219.         }
  220. +
  221.  
  222. +
  223.         if (!is_array($this->_fields[$key]))
  224. +
  225.         {
  226. +
  227.             $this->_fields[$key] = array($this->_fields[$key]);
  228. +
  229.         }
  230. +
  231.  
  232. +
  233.         $this->_fields[$key][] = $value;
  234. +
  235.     }
  236. +
  237.  
  238. +
  239.     /**
  240. +
  241.      * Get the names of all fields in this document
  242. +
  243.      *
  244. +
  245.      * @return array 
  246. +
  247.      */
  248. +
  249.     public function getFieldNames()
  250. +
  251.     {
  252. +
  253.         return array_keys($this->_fields);
  254. +
  255.     }
  256. +
  257.  
  258. +
  259.     /**
  260. +
  261.      * Iterator implementation function, proxies to _fields. Allows usage:
  262. +
  263.      *
  264. +
  265.      * <code>
  266. +
  267.      * foreach ($document as $key => $value)
  268. +
  269.      * {
  270. +
  271.      *     ...
  272. +
  273.      * }
  274. +
  275.      * </code>
  276. +
  277.      */
  278. +
  279.     public function rewind() {
  280. +
  281.         reset($this->_fields);
  282. +
  283.     }
  284. +
  285.  
  286. +
  287.     /**
  288. +
  289.      * Iterator implementation function, proxies to _fields. Allows usage:
  290. +
  291.      *
  292. +
  293.      * <code>
  294. +
  295.      * foreach ($document as $key => $value)
  296. +
  297.      * {
  298. +
  299.      *     ...
  300. +
  301.      * }
  302. +
  303.      * </code>
  304. +
  305.      */
  306. +
  307.     public function current() {
  308. +
  309.         return current($this->_fields);
  310. +
  311.     }
  312. +
  313.  
  314. +
  315.     /**
  316. +
  317.      * Iterator implementation function, proxies to _fields. Allows usage:
  318. +
  319.      *
  320. +
  321.      * <code>
  322. +
  323.      * foreach ($document as $key => $value)
  324. +
  325.      * {
  326. +
  327.      *     ...
  328. +
  329.      * }
  330. +
  331.      * </code>
  332. +
  333.      */
  334. +
  335.     public function key() {
  336. +
  337.         return key($this->_fields);
  338. +
  339.     }
  340. +
  341.  
  342. +
  343.     /**
  344. +
  345.      * Iterator implementation function, proxies to _fields. Allows usage:
  346. +
  347.      *
  348. +
  349.      * <code>
  350. +
  351.      * foreach ($document as $key => $value)
  352. +
  353.      * {
  354. +
  355.      *     ...
  356. +
  357.      * }
  358. +
  359.      * </code>
  360. +
  361.      */
  362. +
  363.     public function next() {
  364. +
  365.         return next($this->_fields);
  366. +
  367.     }
  368. +
  369.  
  370. +
  371.     /**
  372. +
  373.      * Iterator implementation function, proxies to _fields. Allows usage:
  374. +
  375.      *
  376. +
  377.      * <code>
  378. +
  379.      * foreach ($document as $key => $value)
  380. +
  381.      * {
  382. +
  383.      *     ...
  384. +
  385.      * }
  386. +
  387.      * </code>
  388. +
  389.      */
  390. +
  391.     public function valid() {
  392. +
  393.         return current($this->_fields) !== false;
  394. +
  395.     }
  396. +
  397. }
  398. +
+
+

+ Documentation generated on Tue, 02 Sep 2008 10:45:04 -0400 by phpDocumentor 1.4.0 +

+ + Index: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/blank.html =================================================================== RCS file: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/blank.html diff -N sites/all/modules/apachesolr/SolrPhpClient/phpdocs/blank.html --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sites/all/modules/apachesolr/SolrPhpClient/phpdocs/blank.html 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,13 @@ + + + Generated Documentation + + + + +

Generated Documentation

+Welcome to Apache!
+
+This documentation was generated by phpDocumentor v1.4.0
+ + Index: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_Document.html =================================================================== RCS file: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_Document.html diff -N sites/all/modules/apachesolr/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_Document.html --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sites/all/modules/apachesolr/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_Document.html 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,560 @@ + + + + + + Docs For Class Apache_Solr_Document + + + + +
+ +

Class Apache_Solr_Document

+ + +
+
Description
+ +
+

+ Implements interfaces: +

    +
  • Iterator (internal interface)
+

+ +

Holds Key / Value pairs that represent a Solr Document. Field values can be accessed by direct dereferencing such as:

+

$document->title = 'Something'; echo $document->title; ... </code>

Additionally, the field values can be iterated with foreach

  1.  foreach ($document as $key => $value)
  2. +
  3.  {
  4. +
  5.  ...
  6. +
  7.  }
  8. +

+

+ Located in /Document.php (line 42) +

+ + +

+	
+			
+
+ + + + +
+
Variable Summary
+ +
+
+
+ mixed + $_fields +
+
+
+
+ + +
+
Method Summary
+ +
+
+ +
+ void + current + () +
+ +
+ array + getFieldNames + () +
+ +
+ void + key + () +
+ +
+ void + next + () +
+ +
+ void + rewind + () +
+ +
+ void + setMultiValue + (string $key, string $value) +
+ +
+ void + valid + () +
+ +
+ mixed + __get + (string $key) +
+ +
+ boolean + __isset + (string $key) +
+ +
+ void + __set + (string $key, mixed $value) +
+ +
+ void + __unset + (string $key) +
+
+
+
+ + +
+
Variables
+ +
+ + +
+ +
+ + mixed + $_fields + = array() (line 44) + +
+ + +
    +
  • access: protected
  • +
+ + + + + +
+ + +
+
+ + +
+
Methods
+ +
+ + +
+ +
+ current (line 154) +
+ + +

Iterator implementation function, proxies to _fields. Allows usage:

+

  1.  foreach ($document as $key => $value)
  2. +
  3.  {
  4. +
  5.      ...
  6. +
  7.  }
  8. +

+
    +
  • access: public
  • +
+ +
+ void + + current + + () +
+ + +
+
Implementation of:
+
+
Iterator::current
+
+ +
+ +
+ +
+ getFieldNames (line 125) +
+ + +

Get the names of all fields in this document

+
    +
  • access: public
  • +
+ +
+ array + + getFieldNames + + () +
+ + + +
+ +
+ +
+ key (line 168) +
+ + +

Iterator implementation function, proxies to _fields. Allows usage:

+

  1.  foreach ($document as $key => $value)
  2. +
  3.  {
  4. +
  5.      ...
  6. +
  7.  }
  8. +

+
    +
  • access: public
  • +
+ +
+ void + + key + + () +
+ + +
+
Implementation of:
+
+
Iterator::key
+
+ +
+ +
+ +
+ next (line 182) +
+ + +

Iterator implementation function, proxies to _fields. Allows usage:

+

  1.  foreach ($document as $key => $value)
  2. +
  3.  {
  4. +
  5.      ...
  6. +
  7.  }
  8. +

+
    +
  • access: public
  • +
+ +
+ void + + next + + () +
+ + +
+
Implementation of:
+
+
Iterator::next
+
+ +
+ +
+ +
+ rewind (line 140) +
+ + +

Iterator implementation function, proxies to _fields. Allows usage:

+

  1.  foreach ($document as $key => $value)
  2. +
  3.  {
  4. +
  5.      ...
  6. +
  7.  }
  8. +

+
    +
  • access: public
  • +
+ +
+ void + + rewind + + () +
+ + +
+
Implementation of:
+
+
Iterator::rewind
+
+ +
+ +
+ +
+ setMultiValue (line 105) +
+ + +

Handle the array manipulation for a multi-valued field

+
    +
  • access: public
  • +
+ +
+ void + + setMultiValue + + (string $key, string $value) +
+ +
    +
  • + string + $key
  • +
  • + string + $value
  • +
+ + +
+ +
+ +
+ valid (line 196) +
+ + +

Iterator implementation function, proxies to _fields. Allows usage:

+

  1.  foreach ($document as $key => $value)
  2. +
  3.  {
  4. +
  5.      ...
  6. +
  7.  }
  8. +

+
    +
  • access: public
  • +
+ +
+ void + + valid + + () +
+ + +
+
Implementation of:
+
+
Iterator::valid
+
+ +
+ +
+ +
+ __get (line 52) +
+ + +

Magic get for field values

+
    +
  • access: public
  • +
+ +
+ mixed + + __get + + (string $key) +
+ +
    +
  • + string + $key
  • +
+ + +
+ +
+ +
+ __isset (line 80) +
+ + +

Magic isset for fields values. Do no call directly. Allows usage:

+

  1.  isset($document->some_field);
  2. +

+
    +
  • access: public
  • +
+ +
+ boolean + + __isset + + (string $key) +
+ +
    +
  • + string + $key
  • +
+ + +
+ +
+ +
+ __set (line 65) +
+ + +

Magic set for field values. Multi-valued fields should be set as arrays or instead use the setMultiValue(...) function which will automatically make sure the field is an array.

+
    +
  • access: public
  • +
+ +
+ void + + __set + + (string $key, mixed $value) +
+ +
    +
  • + string + $key
  • +
  • + mixed + $value
  • +
+ + +
+ +
+ +
+ __unset (line 94) +
+ + +

Magic unset for field values. Do no call directly. Allows usage:

+

  1.  unset($document->some_field);
  2. +

+
    +
  • access: public
  • +
+ +
+ void + + __unset + + (string $key) +
+ +
    +
  • + string + $key
  • +
+ + +
+ +
+
+ + +

+ Documentation generated on Tue, 02 Sep 2008 10:45:04 -0400 by phpDocumentor 1.4.0 +

+
+ Index: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/media/banner.css =================================================================== RCS file: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/media/banner.css diff -N sites/all/modules/apachesolr/SolrPhpClient/phpdocs/media/banner.css --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sites/all/modules/apachesolr/SolrPhpClient/phpdocs/media/banner.css 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,32 @@ +body +{ + background-color: #DDDDDD; + margin: 0px; + padding: 0px; +} + +/* Banner (top bar) classes */ + +.banner { } + +.banner-menu +{ + clear: both; + padding: .5em; + border-top: 2px solid #999999; +} + +.banner-title +{ + text-align: right; + font-size: 20pt; + font-weight: bold; + margin: .2em; +} + +.package-selector +{ + background-color: #CCCCCC; + border: 1px solid black; + color: blue; +} Index: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/classtrees_Apache.html =================================================================== RCS file: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/classtrees_Apache.html diff -N sites/all/modules/apachesolr/SolrPhpClient/phpdocs/classtrees_Apache.html --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sites/all/modules/apachesolr/SolrPhpClient/phpdocs/classtrees_Apache.html 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,37 @@ + + + + + + + + + + + + + +

+ +

+

Root class Apache_Solr_Document

+ + +

Root class Apache_Solr_Response

+ + +

Root class Apache_Solr_Service

+ + +

Root class Apache_Solr_Service_Balancer

+ + +

+ Documentation generated on Tue, 02 Sep 2008 10:45:03 -0400 by phpDocumentor 1.4.0 +

+ + Index: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/Apache/Solr/_Response.php.html =================================================================== RCS file: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/Apache/Solr/_Response.php.html diff -N sites/all/modules/apachesolr/SolrPhpClient/phpdocs/Apache/Solr/_Response.php.html --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sites/all/modules/apachesolr/SolrPhpClient/phpdocs/Apache/Solr/_Response.php.html 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,67 @@ + + + + + + Docs for page Response.php + + + + +
+ +

/Response.php

+ + +
+
Description
+ +
+ + + +
+
+ + +
+
Classes
+ +
+ + + + + + + + + +
ClassDescription
+ Apache_Solr_Response + + Represents a Solr response. Parses the raw response into a set of stdClass objects and associative arrays for easy access. +
+
+
+ + + + + +

+ Documentation generated on Tue, 02 Sep 2008 10:45:04 -0400 by phpDocumentor 1.4.0 +

+
+ Index: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_Response.html =================================================================== RCS file: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_Response.html diff -N sites/all/modules/apachesolr/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_Response.html --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sites/all/modules/apachesolr/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_Response.html 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,603 @@ + + + + + + Docs For Class Apache_Solr_Response + + + + +
+ +

Class Apache_Solr_Response

+ + +
+
Description
+ +
+ +

Represents a Solr response. Parses the raw response into a set of stdClass objects and associative arrays for easy access.

+

Currently requires json_decode which is bundled with PHP >= 5.2.0, Alternatively can be installed with PECL. Zend Framework also includes a purely PHP solution.

+
    +
  • todo: When Solr 1.3 is released, possibly convert to use PHP or Serialized PHP output writer
  • +
+

+ Located in /Response.php (line 32) +

+ + +

+	
+			
+
+ + + + +
+
Variable Summary
+ +
+
+ +
+ boolean + $_createDocuments +
+
+ mixed + $_encoding +
+
+ string + $_httpStatus +
+
+ mixed + $_httpStatusMessage +
+
+ boolean + $_isParsed +
+
+ mixed + $_parsedData +
+
+ string + $_rawResponse +
+
+ mixed + $_type +
+
+
+
+ + +
+
Method Summary
+ +
+
+ +
+ Apache_Solr_Response + __construct + (string $rawResponse, [array $httpHeaders = array()], [boolean $createDocuments = true], [boolean $collapseSingleValueArrays = true]) +
+ +
+ string + getEncoding + () +
+ +
+ integer + getHttpStatus + () +
+ +
+ string + getHttpStatusMessage + () +
+ +
+ string + getRawResponse + () +
+ +
+ string + getType + () +
+ +
+ void + _parseData + () +
+ +
+ unknown + __get + (unknown_type $key) +
+
+
+
+ + +
+
Variables
+ +
+ + +
+ +
+ + mixed + $_collapseSingleValueArrays + = true (line 69) + +
+ + +
    +
  • access: protected
  • +
+ + + + + +
+ +
+ +
+ + boolean + $_createDocuments + = true (line 68) + +
+ + +

Data parsing flags. Determines what extra processing should be done after the data is initially converted to a data structure.

+
    +
  • access: protected
  • +
+ + + + + +
+ +
+ +
+ + mixed + $_encoding + (line 46) + +
+ + +
    +
  • access: protected
  • +
+ + + + + +
+ +
+ +
+ + string + $_httpStatus + (line 46) + +
+ + +

Parsed values from the passed in http headers

+
    +
  • access: protected
  • +
+ + + + + +
+ +
+ +
+ + mixed + $_httpStatusMessage + (line 46) + +
+ + +
    +
  • access: protected
  • +
+ + + + + +
+ +
+ +
+ + boolean + $_isParsed + = false (line 53) + +
+ + +

Whether the raw response has been parsed

+
    +
  • access: protected
  • +
+ + + + + +
+ +
+ +
+ + mixed + $_parsedData + (line 60) + +
+ + +

Parsed representation of the data

+
    +
  • access: protected
  • +
+ + + + + +
+ +
+ +
+ + string + $_rawResponse + (line 39) + +
+ + +

Holds the raw response used in construction

+
    +
  • access: protected
  • +
+ + + + + +
+ +
+ +
+ + mixed + $_type + (line 46) + +
+ + +
    +
  • access: protected
  • +
+ + + + + +
+ + +
+
+ + +
+
Methods
+ +
+ + +
+ +
+ Constructor __construct (line 79) +
+ + +

Constructor. Takes the raw HTTP response body and the exploded HTTP headers

+
    +
  • access: public
  • +
+ +
+ Apache_Solr_Response + + __construct + + (string $rawResponse, [array $httpHeaders = array()], [boolean $createDocuments = true], [boolean $collapseSingleValueArrays = true]) +
+ +
    +
  • + string + $rawResponse
  • +
  • + array + $httpHeaders
  • +
  • + boolean + $createDocuments: Whether to convert the documents json_decoded as stdClass instances to Apache_Solr_Document instances
  • +
  • + boolean + $collapseSingleValueArrays: Whether to make multivalued fields appear as single values
  • +
+ + +
+ +
+ +
+ getEncoding (line 181) +
+ + +

Get character encoding of this response. Should usually be utf-8, but just in case

+
    +
  • access: public
  • +
+ +
+ string + + getEncoding + + () +
+ + + +
+ +
+ +
+ getHttpStatus (line 151) +
+ + +

Get the HTTP status code

+
    +
  • access: public
  • +
+ +
+ integer + + getHttpStatus + + () +
+ + + +
+ +
+ +
+ getHttpStatusMessage (line 161) +
+ + +

Get the HTTP status message of the response

+
    +
  • access: public
  • +
+ +
+ string + + getHttpStatusMessage + + () +
+ + + +
+ +
+ +
+ getRawResponse (line 191) +
+ + +

Get the raw response as it was given to this object

+
    +
  • access: public
  • +
+ +
+ string + + getRawResponse + + () +
+ + + +
+ +
+ +
+ getType (line 171) +
+ + +

Get content type of this Solr response

+
    +
  • access: public
  • +
+ +
+ string + + getType + + () +
+ + + +
+ +
+ +
+ _parseData (line 221) +
+ + +

Parse the raw response into the parsed_data array for access

+
    +
  • access: protected
  • +
+ +
+ void + + _parseData + + () +
+ + + +
+ +
+ +
+ __get (line 202) +
+ + +

Magic get to expose the parsed data and to lazily load it

+
    +
  • access: public
  • +
+ +
+ unknown + + __get + + (unknown_type $key) +
+ +
    +
  • + unknown_type + $key
  • +
+ + +
+ +
+
+ + +

+ Documentation generated on Tue, 02 Sep 2008 10:45:04 -0400 by phpDocumentor 1.4.0 +

+
+ Index: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/Apache/Solr/_Document.php.html =================================================================== RCS file: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/Apache/Solr/_Document.php.html diff -N sites/all/modules/apachesolr/SolrPhpClient/phpdocs/Apache/Solr/_Document.php.html --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sites/all/modules/apachesolr/SolrPhpClient/phpdocs/Apache/Solr/_Document.php.html 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,67 @@ + + + + + + Docs for page Document.php + + + + +
+ +

/Document.php

+ + +
+
Description
+ +
+ + + +
+
+ + +
+
Classes
+ +
+ + + + + + + + + +
ClassDescription
+ Apache_Solr_Document + + Holds Key / Value pairs that represent a Solr Document. Field values can be accessed by direct dereferencing such as: +
+
+
+ + + + + +

+ Documentation generated on Tue, 02 Sep 2008 10:45:04 -0400 by phpDocumentor 1.4.0 +

+
+ Index: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/media/stylesheet.css =================================================================== RCS file: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/media/stylesheet.css diff -N sites/all/modules/apachesolr/SolrPhpClient/phpdocs/media/stylesheet.css --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sites/all/modules/apachesolr/SolrPhpClient/phpdocs/media/stylesheet.css 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,142 @@ +a { color: #0000FF; text-decoration: none; } +a:hover { color: #FF0000; text-decoration: underline; } +a:active { color: #FF0000; text-decoration: underline; } + +body { background-color: #EEEEEE; font-family: Verdana, Arial, sans-serif } +body, table { font-size: 10pt } +a img { border: 0px; } +dd { margin-left: 0px; padding-left: 1em; } + +/* Page layout/boxes */ + +.info-box {} +.info-box-title { margin: 1em 0em 0em 0em; padding: .25em; font-weight: normal; font-size: 14pt; border: 2px solid #999999; background-color: #DDDDDD } +.info-box-body { border: 1px solid #999999; padding: .5em; background-color: #F8F8F8; } +.nav-bar { font-size: 8pt; white-space: nowrap; text-align: right; padding: .2em; margin: 0em 0em 1em 0em; } + +.oddrow { background-color: #DDDDDD; border: 1px solid #999999; padding: .5em; margin-bottom: 1em} +.evenrow { background-color: #DDDDDD; border: 1px solid #999999; padding: .5em; margin-bottom: 1em} + +.page-body { max-width: 800px; margin: auto; } +.tree dl { margin: 0px } + +/* Index formatting classes */ + +.index-item-body { margin-top: .5em; margin-bottom: .5em} +.index-item-description { margin-top: .25em } +.index-item-details { font-weight: normal; font-style: italic; font-size: 8pt } +.index-letter-section { background-color: #EEEEEE; border: 1px dotted #999999; padding: .5em; margin-bottom: 1em} +.index-letter-title { font-size: 12pt; font-weight: bold } +.index-letter-menu { text-align: center; margin: 1em } +.index-letter { font-size: 12pt } + +/* Docbook classes */ + +.description {} +.short-description { font-weight: bold; color: #666666; } +.tags { padding-left: 0em; margin-left: 3em; color: #666666; list-style-type: square; } +.parameters { padding-left: 0em; margin-left: 3em; font-style: italic; list-style-type: square; } +.redefinitions { font-size: 8pt; padding-left: 0em; margin-left: 2em; } +.package { } +.package-title { font-weight: bold; font-size: 14pt; border-bottom: 1px solid black } +.package-details { font-size: 85%; } +.sub-package { font-weight: bold; font-size: 120% } +.tutorial { border-width: thin; border-color: #0066ff } +.tutorial-nav-box { width: 100%; border: 2px solid #999999; background-color: #DDDDDD } +.nav-button-disabled { color: #999999; } +.nav-button:active, +.nav-button:focus, +.nav-button:hover { background-color: #AAAAAA; outline: 1px solid #666666; text-decoration: none } +.folder-title { font-style: italic } + +/* Generic formatting */ + +.field { font-weight: bold; } +.detail { font-size: 8pt; } +.notes { font-style: italic; font-size: 8pt; } +.separator { background-color: #999999; height: 2px; } +.warning { color: #FF6600; } +.disabled { font-style: italic; color: #999999; } + +/* Code elements */ + +.line-number { } + +.class-table { width: 100%; } +.class-table-header { border-bottom: 1px dotted #666666; text-align: left} +.class-name { color: #000000; font-weight: bold; } + +.method-summary { padding-left: 1em; font-size: 8pt } +.method-header { } +.method-definition { margin-bottom: .3em } +.method-title { font-weight: bold; } +.method-name { font-weight: bold; } +.method-signature { font-size: 85%; color: #0066BB; margin: .5em 0em } +.method-result { font-style: italic; } + +.var-summary { padding-left: 1em; font-size: 8pt; } +.var-header { } +.var-title { margin-bottom: .3em } +.var-type { color: red; font-weight: bold } +.var-name { font-weight: bold; } +.var-default {} +.var-description { font-weight: normal; color: #000000; } + +.include-title { } +.include-type { font-style: italic; } +.include-name { font-weight: bold; } + +.const-title { } +.const-name { font-weight: bold; } + +/* Syntax highlighting */ + +.src-code { border: 1px solid #336699; padding: 1em; background-color: #EEEEEE; + font-family: 'Courier New', Courier, monospace; font-weight: normal; } +.src-line { font-family: 'Courier New', Courier, monospace; font-weight: normal; } + +.src-comm { color: #666666; } +.src-id { } +.src-inc { color: #0000FF; } +.src-key { color: #0000FF; } +.src-num { color: #CC0000; } +.src-str { color: #66cccc; } +.src-sym { font-weight: bold; } +.src-var { } + +.src-php { font-weight: bold; } + +.src-doc { color: #009999 } +.src-doc-close-template { color: #0000FF } +.src-doc-coretag { color: #0099FF; font-weight: bold } +.src-doc-inlinetag { color: #0099FF } +.src-doc-internal { color: #6699cc } +.src-doc-tag { color: #0080CC } +.src-doc-template { color: #0000FF } +.src-doc-type { font-style: italic } +.src-doc-var { font-style: italic } + +.tute-tag { color: #009999 } +.tute-attribute-name { color: #0000FF } +.tute-attribute-value { color: #0099FF } +.tute-entity { font-weight: bold; } +.tute-comment { font-style: italic } +.tute-inline-tag { color: #636311; font-weight: bold } + +/* tutorial */ + +.authors { } +.author { font-style: italic; font-weight: bold } +.author-blurb { margin: .5em 0em .5em 2em; font-size: 85%; font-weight: normal; font-style: normal } +.example { background-color: #DDDDDD; border: 1px solid #999999; padding: .5em; } +.listing { background-color: #DDDDDD; border: 1px solid #999999; padding: .5em; white-space: nowrap; } +.release-info { font-size: 85%; font-style: italic; margin: 1em 0em } +.ref-title-box { } +.ref-title { } +.ref-purpose { font-style: italic; color: #666666 } +.ref-synopsis { } +.title { font-weight: bold; border-bottom: 1px solid #888888; color: #888888; } +.cmd-synopsis { margin: 1em 0em } +.cmd-title { font-weight: bold } +.toc { margin-left: 2em; padding-left: 0em } + Index: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_Service.php.html =================================================================== RCS file: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_Service.php.html diff -N sites/all/modules/apachesolr/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_Service.php.html --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sites/all/modules/apachesolr/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_Service.php.html 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,905 @@ + + + + + + File Source for Service.php + + + + + +

Source for file Service.php

+

Documentation is available at Service.php

+
+
  1. <?php
  2. +
  3. /**
  4. +
  5.  * @copyright Copyright 2007 Conduit Internet Technologies, Inc. (http://conduit-it.com)
  6. +
  7.  * @license Apache Licence, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
  8. +
  9.  *
  10. +
  11.  *  Licensed under the Apache License, Version 2.0 (the "License");
  12. +
  13.  *  you may not use this file except in compliance with the License.
  14. +
  15.  *  You may obtain a copy of the License at
  16. +
  17.  *
  18. +
  19.  *      http://www.apache.org/licenses/LICENSE-2.0
  20. +
  21.  *
  22. +
  23.  *  Unless required by applicable law or agreed to in writing, software
  24. +
  25.  *  distributed under the License is distributed on an "AS IS" BASIS,
  26. +
  27.  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  28. +
  29.  *  See the License for the specific language governing permissions and
  30. +
  31.  *  limitations under the License.
  32. +
  33.  *
  34. +
  35.  * @package Apache
  36. +
  37.  * @subpackage Solr
  38. +
  39.  * @author Donovan Jimenez <djimenez@conduit-it.com>
  40. +
  41.  */
  42. +
  43.  
  44. +
  45. require_once('Apache/Solr/Document.php');
  46. +
  47. require_once('Apache/Solr/Response.php');
  48. +
  49.  
  50. +
  51. /**
  52. +
  53.  * Starting point for the Solr API. Represents a Solr server resource and has
  54. +
  55.  * methods for pinging, adding, deleting, committing, optimizing and searching.
  56. +
  57.  *
  58. +
  59.  * Example Usage:
  60. +
  61.  * <code>
  62. +
  63.  * ...
  64. +
  65.  * $solr = new Apache_Solr_Service(); //or explicitly new Apache_Solr_Service('localhost', 8180, '/solr')
  66. +
  67.  *
  68. +
  69.  * if ($solr->ping())
  70. +
  71.  * {
  72. +
  73.  *         $solr->deleteByQuery('*:*'); //deletes ALL documents - be careful :)
  74. +
  75.  *
  76. +
  77.  *         $document = new Apache_Solr_Document();
  78. +
  79.  *         $document->id = uniqid(); //or something else suitably unique
  80. +
  81.  *
  82. +
  83.  *         $document->title = 'Some Title';
  84. +
  85.  *         $document->content = 'Some content for this wonderful document. Blah blah blah.';
  86. +
  87.  *
  88. +
  89.  *         $solr->addDocument($document);     //if you're going to be adding documents in bulk using addDocuments
  90. +
  91.  *                                         //with an array of documents is faster
  92. +
  93.  *
  94. +
  95.  *         $solr->commit(); //commit to see the deletes and the document
  96. +
  97.  *         $solr->optimize(); //merges multiple segments into one
  98. +
  99.  *
  100. +
  101.  *         //and the one we all care about, search!
  102. +
  103.  *         //any other common or custom parameters to the request handler can go in the
  104. +
  105.  *         //optional 4th array argument.
  106. +
  107.  *         $solr->search('content:blah', 0, 10, array('sort' => 'timestamp desc'));
  108. +
  109.  * }
  110. +
  111.  * ...
  112. +
  113.  * </code>
  114. +
  115.  *
  116. +
  117.  * @todo Investigate using other HTTP clients other than file_get_contents built-in handler. Could provide performance
  118. +
  119.  *  improvements when dealing with multiple requests by using HTTP's keep alive functionality
  120. +
  121.  */
  122. +
  123. +
  124. {
  125. +
  126.     /**
  127. +
  128.      * Response version we support
  129. +
  130.      */
  131. +
  132.     const SOLR_VERSION = '1.2';
  133. +
  134.  
  135. +
  136.     /**
  137. +
  138.      * Response writer we support
  139. +
  140.      *
  141. +
  142.      * @todo Solr 1.3 release may change this to SerializedPHP or PHP implementation
  143. +
  144.      */
  145. +
  146.     const SOLR_WRITER = 'json';
  147. +
  148.  
  149. +
  150.     /**
  151. +
  152.      * NamedList Treatment constants
  153. +
  154.      */
  155. +
  156.     const NAMED_LIST_FLAT = 'flat';
  157. +
  158.     const NAMED_LIST_MAP = 'map';
  159. +
  160.  
  161. +
  162.     /**
  163. +
  164.      * Servlet mappings
  165. +
  166.      */
  167. +
  168.     const PING_SERVLET = 'admin/ping';
  169. +
  170.     const UPDATE_SERVLET = 'update';
  171. +
  172.     const SEARCH_SERVLET = 'select';
  173. +
  174.     const THREADS_SERVLET = 'admin/threads';
  175. +
  176.  
  177. +
  178.     /**
  179. +
  180.      * Server identification strings
  181. +
  182.      *
  183. +
  184.      * @var string 
  185. +
  186.      */
  187. +
  188.     protected $_host, $_port, $_path;
  189. +
  190.  
  191. +
  192.     /**
  193. +
  194.      * Whether {@link Apache_Solr_Response} objects should create {@link Apache_Solr_Document}s in
  195. +
  196.      * the returned parsed data
  197. +
  198.      *
  199. +
  200.      * @var boolean 
  201. +
  202.      */
  203. +
  204.     protected $_createDocuments = true;
  205. +
  206.  
  207. +
  208.     /**
  209. +
  210.      * Whether {@link Apache_Solr_Response} objects should have multivalue fields with only a single value
  211. +
  212.      * collapsed to appear as a single value would.
  213. +
  214.      *
  215. +
  216.      * @var boolean 
  217. +
  218.      */
  219. +
  220.     protected $_collapseSingleValueArrays = true;
  221. +
  222.  
  223. +
  224.     /**
  225. +
  226.      * How NamedLists should be formatted in the output.  This specifically effects facet counts. Valid values
  227. +
  228.      * are {@link Apache_Solr_Service::NAMED_LIST_MAP} (default) or {@link Apache_Solr_Service::NAMED_LIST_FLAT}.
  229. +
  230.      *
  231. +
  232.      * @var string 
  233. +
  234.      */
  235. +
  236.     protected $_namedListTreatment = self::NAMED_LIST_MAP;
  237. +
  238.  
  239. +
  240.     /**
  241. +
  242.      * Query delimiters. Someone might want to be able to change
  243. +
  244.      * these (to use &amp; instead of & for example), so I've provided them.
  245. +
  246.      *
  247. +
  248.      * @var string 
  249. +
  250.      */
  251. +
  252.     protected $_queryDelimiter = '?', $_queryStringDelimiter = '&';
  253. +
  254.  
  255. +
  256.     /**
  257. +
  258.      * Constructed servlet full path URLs
  259. +
  260.      *
  261. +
  262.      * @var string 
  263. +
  264.      */
  265. +
  266.     protected $_updateUrl, $_searchUrl, $_threadsUrl;
  267. +
  268.  
  269. +
  270.     /**
  271. +
  272.      * Keep track of whether our URLs have been constructed
  273. +
  274.      *
  275. +
  276.      * @var boolean 
  277. +
  278.      */
  279. +
  280.     protected $_urlsInited = false;
  281. +
  282.  
  283. +
  284.     /**
  285. +
  286.      * Stream context for posting
  287. +
  288.      *
  289. +
  290.      * @var resource 
  291. +
  292.      */
  293. +
  294.     protected $_postContext;
  295. +
  296.  
  297. +
  298.     /**
  299. +
  300.      * Escape a value for special query characters such as ':', '(', ')', '*', '?', etc.
  301. +
  302.      *
  303. +
  304.      * NOTE: inside a phrase fewer characters need escaped, use {@link Apache_Solr_Service::escapePhrase()} instead
  305. +
  306.      *
  307. +
  308.      * @param string $value 
  309. +
  310.      * @return string 
  311. +
  312.      */
  313. +
  314.     static public function escape($value)
  315. +
  316.     {
  317. +
  318.         //list taken from http://lucene.apache.org/java/docs/queryparsersyntax.html#Escaping%20Special%20Characters
  319. +
  320.         $pattern = '/(\+|-|&&|\|\||!|\(|\)|\{|}|\[|]|\^|"|~|\*|\?|:|\\\)/';
  321. +
  322.         $replace = '\\\$1';
  323. +
  324.  
  325. +
  326.         return preg_replace($pattern, $replace, $value);
  327. +
  328.     }
  329. +
  330.  
  331. +
  332.     /**
  333. +
  334.      * Escape a value meant to be contained in a phrase for special query characters
  335. +
  336.      *
  337. +
  338.      * @param string $value 
  339. +
  340.      * @return string 
  341. +
  342.      */
  343. +
  344.     static public function escapePhrase($value)
  345. +
  346.     {
  347. +
  348.         $pattern = '/("|\\\)/';
  349. +
  350.         $replace = '\\\$1';
  351. +
  352.  
  353. +
  354.         return preg_replace($pattern, $replace, $value);
  355. +
  356.     }
  357. +
  358.  
  359. +
  360.     /**
  361. +
  362.      * Convenience function for creating phrase syntax from a value
  363. +
  364.      *
  365. +
  366.      * @param string $value 
  367. +
  368.      * @return string 
  369. +
  370.      */
  371. +
  372.     static public function phrase($value)
  373. +
  374.     {
  375. +
  376.         return '"' . self::escapePhrase($value) . '"';
  377. +
  378.     }
  379. +
  380.  
  381. +
  382.     /**
  383. +
  384.      * Constructor. All parameters are optional and will take on default values
  385. +
  386.      * if not specified.
  387. +
  388.      *
  389. +
  390.      * @param string $host 
  391. +
  392.      * @param string $port 
  393. +
  394.      * @param string $path 
  395. +
  396.      */
  397. +
  398.     public function __construct($host = 'localhost', $port = 8180, $path = '/solr/')
  399. +
  400.     {
  401. +
  402.         $this->setHost($host);
  403. +
  404.         $this->setPort($port);
  405. +
  406.         $this->setPath($path);
  407. +
  408.  
  409. +
  410.         $this->_initUrls();
  411. +
  412.  
  413. +
  414.         //set up the stream context for posting with file_get_contents
  415. +
  416.         $contextOpts = array(
  417. +
  418.             'http' => array(
  419. +
  420.                 'method' => 'POST',
  421. +
  422.                 'header' => "Content-Type: text/xml; charset=UTF-8\r\n" //php.net example showed \r\n at the end
  423. +
  424.             )
  425. +
  426.         );
  427. +
  428.  
  429. +
  430.         $this->_postContext = stream_context_create($contextOpts);
  431. +
  432.     }
  433. +
  434.  
  435. +
  436.     /**
  437. +
  438.      * Return a valid http URL given this server's host, port and path and a provided servlet name
  439. +
  440.      *
  441. +
  442.      * @param string $servlet 
  443. +
  444.      * @return string 
  445. +
  446.      */
  447. +
  448.     protected function _constructUrl($servlet, $params = array())
  449. +
  450.     {
  451. +
  452.         if (count($params))
  453. +
  454.         {
  455. +
  456.             //escape all parameters appropriately for inclusion in the query string
  457. +
  458.             $escapedParams = array();
  459. +
  460.  
  461. +
  462.             foreach ($params as $key => $value)
  463. +
  464.             {
  465. +
  466.                 $escapedParams[] = urlencode($key) . '=' . urlencode($value);
  467. +
  468.             }
  469. +
  470.  
  471. +
  472.             $queryString = $this->_queryDelimiter . implode($this->_queryStringDelimiter, $escapedParams);
  473. +
  474.         }
  475. +
  476.         else
  477. +
  478.         {
  479. +
  480.             $queryString = '';
  481. +
  482.         }
  483. +
  484.  
  485. +
  486.         return 'http://' . $this->_host . ':' . $this->_port . $this->_path . $servlet . $queryString;
  487. +
  488.     }
  489. +
  490.  
  491. +
  492.     /**
  493. +
  494.      * Construct the Full URLs for the three servlets we reference
  495. +
  496.      */
  497. +
  498.     protected function _initUrls()
  499. +
  500.     {
  501. +
  502.         //Initialize our full servlet URLs now that we have server information
  503. +
  504.         $this->_updateUrl = $this->_constructUrl(self::UPDATE_SERVLET, array('wt' => self::SOLR_WRITER ));
  505. +
  506.         $this->_searchUrl = $this->_constructUrl(self::SEARCH_SERVLET);
  507. +
  508.         $this->_threadsUrl = $this->_constructUrl(self::THREADS_SERVLET, array('wt' => self::SOLR_WRITER ));
  509. +
  510.  
  511. +
  512.         $this->_urlsInited = true;
  513. +
  514.     }
  515. +
  516.  
  517. +
  518.     /**
  519. +
  520.      * Central method for making a get operation against this Solr Server
  521. +
  522.      *
  523. +
  524.      * @param string $url 
  525. +
  526.      * @param float $timeout Read timeout in seconds
  527. +
  528.      * @return Apache_Solr_Response 
  529. +
  530.      *
  531. +
  532.      * @todo implement timeout ability
  533. +
  534.      * @throws Exception If a non 200 response status is returned
  535. +
  536.      */
  537. +
  538.     protected function _sendRawGet($url, $timeout = FALSE)
  539. +
  540.     {
  541. +
  542.         //$http_response_header is set by file_get_contents
  543. +
  544.         $response = new Apache_Solr_Response(@file_get_contents($url), $http_response_header, $this->_createDocuments, $this->_collapseSingleValueArrays);
  545. +
  546.  
  547. +
  548.         if ($response->getHttpStatus() != 200)
  549. +
  550.         {
  551. +
  552.             throw new Exception('"' . $response->getHttpStatus() . '" Status: ' . $response->getHttpStatusMessage(), $response->getHttpStatus());
  553. +
  554.         }
  555. +
  556.  
  557. +
  558.         return $response;
  559. +
  560.     }
  561. +
  562.  
  563. +
  564.     /**
  565. +
  566.      * Central method for making a post operation against this Solr Server
  567. +
  568.      *
  569. +
  570.      * @param string $url 
  571. +
  572.      * @param string $rawPost 
  573. +
  574.      * @param float $timeout Read timeout in seconds
  575. +
  576.      * @param string $contentType 
  577. +
  578.      * @return Apache_Solr_Response 
  579. +
  580.      *
  581. +
  582.      * @throws Exception If a non 200 response status is returned
  583. +
  584.      */
  585. +
  586.     protected function _sendRawPost($url, $rawPost, $timeout = FALSE, $contentType = 'text/xml; charset=UTF-8')
  587. +
  588.     {
  589. +
  590.         //ensure content type is correct
  591. +
  592.         stream_context_set_option($this->_postContext, 'http', 'header', 'Content-Type: ' . $contentType);
  593. +
  594.  
  595. +
  596.         //set the read timeout if specified
  597. +
  598.         if ($timeout !== FALSE)
  599. +
  600.         {
  601. +
  602.             stream_context_set_option($this->_postContext, 'http', 'timeout', $timeout);
  603. +
  604.         }
  605. +
  606.  
  607. +
  608.         //set the content
  609. +
  610.         stream_context_set_option($this->_postContext, 'http', 'content', $rawPost);
  611. +
  612.  
  613. +
  614.         //$http_response_header is set by file_get_contents
  615. +
  616.         $response = new Apache_Solr_Response(@file_get_contents($url, false, $this->_postContext), $http_response_header, $this->_createDocuments, $this->_collapseSingleValueArrays);
  617. +
  618.  
  619. +
  620.         if ($response->getHttpStatus() != 200)
  621. +
  622.         {
  623. +
  624.             throw new Exception('"' . $response->getHttpStatus() . '" Status: ' . $response->getHttpStatusMessage(), $response->getHttpStatus());
  625. +
  626.         }
  627. +
  628.  
  629. +
  630.         return $response;
  631. +
  632.     }
  633. +
  634.  
  635. +
  636.     /**
  637. +
  638.      * Returns the set host
  639. +
  640.      *
  641. +
  642.      * @return string 
  643. +
  644.      */
  645. +
  646.     public function getHost()
  647. +
  648.     {
  649. +
  650.         return $this->_host;
  651. +
  652.     }
  653. +
  654.  
  655. +
  656.     /**
  657. +
  658.      * Set the host used. If empty will fallback to constants
  659. +
  660.      *
  661. +
  662.      * @param string $host 
  663. +
  664.      */
  665. +
  666.     public function setHost($host)
  667. +
  668.     {
  669. +
  670.         //Use the provided host or use the default
  671. +
  672.         if (empty($host))
  673. +
  674.         {
  675. +
  676.             throw new Exception('Host parameter is empty');
  677. +
  678.         }
  679. +
  680.         else
  681. +
  682.         {
  683. +
  684.             $this->_host = $host;
  685. +
  686.         }
  687. +
  688.  
  689. +
  690.         if ($this->_urlsInited)
  691. +
  692.         {
  693. +
  694.             $this->_initUrls();
  695. +
  696.         }
  697. +
  698.     }
  699. +
  700.  
  701. +
  702.     /**
  703. +
  704.      * Get the set port
  705. +
  706.      *
  707. +
  708.      * @return integer 
  709. +
  710.      */
  711. +
  712.     public function getPort()
  713. +
  714.     {
  715. +
  716.         return $this->_port;
  717. +
  718.     }
  719. +
  720.  
  721. +
  722.     /**
  723. +
  724.      * Set the port used. If empty will fallback to constants
  725. +
  726.      *
  727. +
  728.      * @param integer $port 
  729. +
  730.      */
  731. +
  732.     public function setPort($port)
  733. +
  734.     {
  735. +
  736.         //Use the provided port or use the default
  737. +
  738.         $port = (int) $port;
  739. +
  740.  
  741. +
  742.         if ($port <= 0)
  743. +
  744.         {
  745. +
  746.             throw new Exception('Port is not a valid port number');
  747. +
  748.         }
  749. +
  750.         else
  751. +
  752.         {
  753. +
  754.             $this->_port = $port;
  755. +
  756.         }
  757. +
  758.  
  759. +
  760.         if ($this->_urlsInited)
  761. +
  762.         {
  763. +
  764.             $this->_initUrls();
  765. +
  766.         }
  767. +
  768.     }
  769. +
  770.  
  771. +
  772.     /**
  773. +
  774.      * Get the set path.
  775. +
  776.      *
  777. +
  778.      * @return string 
  779. +
  780.      */
  781. +
  782.     public function getPath()
  783. +
  784.     {
  785. +
  786.         return $this->_path;
  787. +
  788.     }
  789. +
  790.  
  791. +
  792.     /**
  793. +
  794.      * Set the path used. If empty will fallback to constants
  795. +
  796.      *
  797. +
  798.      * @param string $path 
  799. +
  800.      */
  801. +
  802.     public function setPath($path)
  803. +
  804.     {
  805. +
  806.         $path = trim($path, '/');
  807. +
  808.  
  809. +
  810.         $this->_path = '/' . $path . '/';
  811. +
  812.  
  813. +
  814.         if ($this->_urlsInited)
  815. +
  816.         {
  817. +
  818.             $this->_initUrls();
  819. +
  820.         }
  821. +
  822.     }
  823. +
  824.  
  825. +
  826.     /**
  827. +
  828.      * Set the create documents flag. This determines whether {@link Apache_Solr_Response} objects will
  829. +
  830.      * parse the response and create {@link Apache_Solr_Document} instances in place.
  831. +
  832.      *
  833. +
  834.      * @param unknown_type $createDocuments 
  835. +
  836.      */
  837. +
  838.     public function setCreateDocuments($createDocuments)
  839. +
  840.     {
  841. +
  842.         $this->_createDocuments = (bool) $createDocuments;
  843. +
  844.     }
  845. +
  846.  
  847. +
  848.     /**
  849. +
  850.      * Get the current state of teh create documents flag.
  851. +
  852.      *
  853. +
  854.      * @return boolean 
  855. +
  856.      */
  857. +
  858.     public function getCreateDocuments()
  859. +
  860.     {
  861. +
  862.         return $this->_createDocuments;
  863. +
  864.     }
  865. +
  866.  
  867. +
  868.     /**
  869. +
  870.      * Set the collapse single value arrays flag.
  871. +
  872.      *
  873. +
  874.      * @param boolean $collapseSingleValueArrays 
  875. +
  876.      */
  877. +
  878.     public function setCollapseSingleValueArrays($collapseSingleValueArrays)
  879. +
  880.     {
  881. +
  882.         $this->_collapseSingleValueArrays = (bool) $collapseSingleValueArrays;
  883. +
  884.     }
  885. +
  886.  
  887. +
  888.     /**
  889. +
  890.      * Get the current state of the collapse single value arrays flag.
  891. +
  892.      *
  893. +
  894.      * @return boolean 
  895. +
  896.      */
  897. +
  898.     public function getCollapseSingleValueArrays()
  899. +
  900.     {
  901. +
  902.         return $this->_collapseSingleValueArrays;
  903. +
  904.     }
  905. +
  906.  
  907. +
  908.     /**
  909. +
  910.      * Set how NamedLists should be formatted in the response data. This mainly effects
  911. +
  912.      * the facet counts format.
  913. +
  914.      *
  915. +
  916.      * @param string $namedListTreatment 
  917. +
  918.      * @throws Exception If invalid option is set
  919. +
  920.      */
  921. +
  922.     public function setNamedListTreatmet($namedListTreatment)
  923. +
  924.     {
  925. +
  926.         switch ((string) $namedListTreatment)
  927. +
  928.         {
  929. +
  930.             case Apache_Solr_Service::NAMED_LIST_FLAT:
  931. +
  932.                 $this->_namedListTreatment = Apache_Solr_Service::NAMED_LIST_FLAT;
  933. +
  934.                 break;
  935. +
  936.  
  937. +
  938.             case Apache_Solr_Service::NAMED_LIST_MAP:
  939. +
  940.                 $this->_namedListTreatment = Apache_Solr_Service::NAMED_LIST_MAP;
  941. +
  942.                 break;
  943. +
  944.  
  945. +
  946.             default:
  947. +
  948.                 throw new Exception('Not a valid named list treatement option');
  949. +
  950.         }
  951. +
  952.     }
  953. +
  954.  
  955. +
  956.     /**
  957. +
  958.      * Get the current setting for named list treatment.
  959. +
  960.      *
  961. +
  962.      * @return string 
  963. +
  964.      */
  965. +
  966.     public function getNamedListTreatment()
  967. +
  968.     {
  969. +
  970.         return $this->_namedListTreatment;
  971. +
  972.     }
  973. +
  974.  
  975. +
  976.  
  977. +
  978.     /**
  979. +
  980.      * Set the string used to separate the path form the query string.
  981. +
  982.      * Defaulted to '?'
  983. +
  984.      *
  985. +
  986.      * @param string $queryDelimiter 
  987. +
  988.      */
  989. +
  990.     public function setQueryDelimiter($queryDelimiter)
  991. +
  992.     {
  993. +
  994.         $this->_queryDelimiter = $queryDelimiter;
  995. +
  996.     }
  997. +
  998.  
  999. +
  1000.     /**
  1001. +
  1002.      * Set the string used to separate the parameters in thequery string
  1003. +
  1004.      * Defaulted to '&'
  1005. +
  1006.      *
  1007. +
  1008.      * @param string $queryStringDelimiter 
  1009. +
  1010.      */
  1011. +
  1012.     public function setQueryStringDelimiter($queryStringDelimiter)
  1013. +
  1014.     {
  1015. +
  1016.         $this->_queryStringDelimiter = $queryStringDelimiter;
  1017. +
  1018.     }
  1019. +
  1020.  
  1021. +
  1022.     /**
  1023. +
  1024.      * Call the /admin/ping servlet, can be used to quickly tell if a connection to the
  1025. +
  1026.      * server is able to be made.
  1027. +
  1028.      *
  1029. +
  1030.      * @param float $timeout maximum time to wait for ping in seconds, -1 for unlimited (default is 2)
  1031. +
  1032.      * @return float Actual time taken to ping the server, FALSE if timeout occurs
  1033. +
  1034.      */
  1035. +
  1036.     public function ping($timeout = 2)
  1037. +
  1038.     {
  1039. +
  1040.         $timeout = (float) $timeout;
  1041. +
  1042.  
  1043. +
  1044.         if ($timeout <= 0)
  1045. +
  1046.         {
  1047. +
  1048.             $timeout = -1;
  1049. +
  1050.         }
  1051. +
  1052.  
  1053. +
  1054.         $start = microtime(true);
  1055. +
  1056.  
  1057. +
  1058.         //to prevent strict errors
  1059. +
  1060.         $errno = 0;
  1061. +
  1062.         $errstr = '';
  1063. +
  1064.  
  1065. +
  1066.         //try to connect to the host with timeout
  1067. +
  1068.         $fp = fsockopen($this->_host, $this->_port, $errno, $errstr, $timeout);
  1069. +
  1070.  
  1071. +
  1072.         if ($fp)
  1073. +
  1074.         {
  1075. +
  1076.             //If we have a timeout set, then determine the amount of time we have left
  1077. +
  1078.             //in the request and set the stream timeout for the write operation
  1079. +
  1080.             if ($timeout > 0)
  1081. +
  1082.             {
  1083. +
  1084.                 //do the calculation
  1085. +
  1086.                 $writeTimeout = $timeout - (microtime(true) - $start);
  1087. +
  1088.  
  1089. +
  1090.                 //check if we're out of time
  1091. +
  1092.                 if ($writeTimeout <= 0)
  1093. +
  1094.                 {
  1095. +
  1096.                     fclose($fp);
  1097. +
  1098.                     return false;
  1099. +
  1100.                 }
  1101. +
  1102.  
  1103. +
  1104.                 //convert to microseconds and set the stream timeout
  1105. +
  1106.                 $writeTimeoutInMicroseconds = (int) $writeTimeout * 1000000;
  1107. +
  1108.                 stream_set_timeout($fp, 0, $writeTimeoutInMicroseconds);
  1109. +
  1110.             }
  1111. +
  1112.  
  1113. +
  1114.             $request =     'HEAD ' . $this->_path . self::PING_SERVLET . ' HTTP/1.1' . "\r\n" .
  1115. +
  1116.                         'host: ' . $this->_host . "\r\n" .
  1117. +
  1118.                         'Connection: close' . "\r\n" .
  1119. +
  1120.                         "\r\n";
  1121. +
  1122.  
  1123. +
  1124.             fwrite($fp, $request);
  1125. +
  1126.  
  1127. +
  1128.             //check the stream meta data to see if we timed out during the operation
  1129. +
  1130.             $metaData = stream_get_meta_data($fp);
  1131. +
  1132.  
  1133. +
  1134.             if (isset($metaData['timeout']) && $metaData['timeout'])
  1135. +
  1136.             {
  1137. +
  1138.                 fclose($fp);
  1139. +
  1140.                 return false;
  1141. +
  1142.             }
  1143. +
  1144.  
  1145. +
  1146.  
  1147. +
  1148.             //if we have a timeout set and have made it this far, determine the amount of time
  1149. +
  1150.             //still remaining and set the timeout appropriately before the read operation
  1151. +
  1152.             if ($timeout > 0)
  1153. +
  1154.             {
  1155. +
  1156.                 //do the calculation
  1157. +
  1158.                 $readTimeout = $timeout - (microtime(true) - $start);
  1159. +
  1160.  
  1161. +
  1162.                 //check if we've run out of time
  1163. +
  1164.                 if ($readTimeout <= 0)
  1165. +
  1166.                 {
  1167. +
  1168.                     fclose($fp);
  1169. +
  1170.                     return false;
  1171. +
  1172.                 }
  1173. +
  1174.  
  1175. +
  1176.                 //convert to microseconds and set the stream timeout
  1177. +
  1178.                 $readTimeoutInMicroseconds = $readTimeout * 1000000;
  1179. +
  1180.                 stream_set_timeout($fp, 0, $readTimeoutInMicroseconds);
  1181. +
  1182.             }
  1183. +
  1184.  
  1185. +
  1186.             //at the very least we should get a response header line of
  1187. +
  1188.             //HTTP/1.1 200 OK
  1189. +
  1190.             $response = fread($fp, 15);
  1191. +
  1192.  
  1193. +
  1194.             //check the stream meta data to see if we timed out during the operation
  1195. +
  1196.             $metaData = stream_get_meta_data($fp);
  1197. +
  1198.             fclose($fp); //we're done with the connection - ignore the rest
  1199. +
  1200.  
  1201. +
  1202.             if (isset($metaData['timeout']) && $metaData['timeout'])
  1203. +
  1204.             {
  1205. +
  1206.                 return false;
  1207. +
  1208.             }
  1209. +
  1210.  
  1211. +
  1212.             //finally, check the response header line
  1213. +
  1214.             if ($response != 'HTTP/1.1 200 OK')
  1215. +
  1216.             {
  1217. +
  1218.                 return false;
  1219. +
  1220.             }
  1221. +
  1222.  
  1223. +
  1224.             //we made it, return the approximate ping time
  1225. +
  1226.             return microtime(true) - $start;
  1227. +
  1228.         }
  1229. +
  1230.  
  1231. +
  1232.         //we weren't able to make a connection
  1233. +
  1234.         return false;
  1235. +
  1236.     }
  1237. +
  1238.  
  1239. +
  1240.     /**
  1241. +
  1242.      * Call the /admin/threads servlet and retrieve information about all threads in the
  1243. +
  1244.      * Solr servlet's thread group. Useful for diagnostics.
  1245. +
  1246.      *
  1247. +
  1248.      * @return Apache_Solr_Response 
  1249. +
  1250.      *
  1251. +
  1252.      * @throws Exception If an error occurs during the service call
  1253. +
  1254.      */
  1255. +
  1256.     public function threads()
  1257. +
  1258.     {
  1259. +
  1260.         return $this->_sendRawGet($this->_threadsUrl);
  1261. +
  1262.     }
  1263. +
  1264.  
  1265. +
  1266.     /**
  1267. +
  1268.      * Raw Add Method. Takes a raw post body and sends it to the update service.  Post body
  1269. +
  1270.      * should be a complete and well formed "add" xml document.
  1271. +
  1272.      *
  1273. +
  1274.      * @param string $rawPost 
  1275. +
  1276.      * @return Apache_Solr_Response 
  1277. +
  1278.      *
  1279. +
  1280.      * @throws Exception If an error occurs during the service call
  1281. +
  1282.      */
  1283. +
  1284.     public function add($rawPost)
  1285. +
  1286.     {
  1287. +
  1288.         return $this->_sendRawPost($this->_updateUrl, $rawPost);
  1289. +
  1290.     }
  1291. +
  1292.  
  1293. +
  1294.     /**
  1295. +
  1296.      * Add a Solr Document to the index
  1297. +
  1298.      *
  1299. +
  1300.      * @param Apache_Solr_Document $document 
  1301. +
  1302.      * @param boolean $allowDups 
  1303. +
  1304.      * @param boolean $overwritePending 
  1305. +
  1306.      * @param boolean $overwriteCommitted 
  1307. +
  1308.      * @return Apache_Solr_Response 
  1309. +
  1310.      *
  1311. +
  1312.      * @throws Exception If an error occurs during the service call
  1313. +
  1314.      */
  1315. +
  1316.     public function addDocument(Apache_Solr_Document $document, $allowDups = false, $overwritePending = true, $overwriteCommitted = true)
  1317. +
  1318.     {
  1319. +
  1320.         $dupValue = $allowDups ? 'true' : 'false';
  1321. +
  1322.         $pendingValue = $overwritePending ? 'true' : 'false';
  1323. +
  1324.         $committedValue = $overwriteCommitted ? 'true' : 'false';
  1325. +
  1326.  
  1327. +
  1328.         $rawPost = '<add allowDups="' . $dupValue . '" overwritePending="' . $pendingValue . '" overwriteCommitted="' . $committedValue . '">';
  1329. +
  1330.         $rawPost .= $this->_documentToXmlFragment($document);
  1331. +
  1332.         $rawPost .= '</add>';
  1333. +
  1334.  
  1335. +
  1336.         return $this->add($rawPost);
  1337. +
  1338.     }
  1339. +
  1340.  
  1341. +
  1342.     /**
  1343. +
  1344.      * Add an array of Solr Documents to the index all at once
  1345. +
  1346.      *
  1347. +
  1348.      * @param array $documents Should be an array of Apache_Solr_Document instances
  1349. +
  1350.      * @param boolean $allowDups 
  1351. +
  1352.      * @param boolean $overwritePending 
  1353. +
  1354.      * @param boolean $overwriteCommitted 
  1355. +
  1356.      * @return Apache_Solr_Response 
  1357. +
  1358.      *
  1359. +
  1360.      * @throws Exception If an error occurs during the service call
  1361. +
  1362.      */
  1363. +
  1364.     public function addDocuments($documents, $allowDups = false, $overwritePending = true, $overwriteCommitted = true)
  1365. +
  1366.     {
  1367. +
  1368.         $dupValue = $allowDups ? 'true' : 'false';
  1369. +
  1370.         $pendingValue = $overwritePending ? 'true' : 'false';
  1371. +
  1372.         $committedValue = $overwriteCommitted ? 'true' : 'false';
  1373. +
  1374.  
  1375. +
  1376.         $rawPost = '<add allowDups="' . $dupValue . '" overwritePending="' . $pendingValue . '" overwriteCommitted="' . $committedValue . '">';
  1377. +
  1378.  
  1379. +
  1380.         foreach ($documents as $document)
  1381. +
  1382.         {
  1383. +
  1384.             if ($document instanceof Apache_Solr_Document)
  1385. +
  1386.             {
  1387. +
  1388.                 $rawPost .= $this->_documentToXmlFragment($document);
  1389. +
  1390.             }
  1391. +
  1392.         }
  1393. +
  1394.  
  1395. +
  1396.         $rawPost .= '</add>';
  1397. +
  1398.  
  1399. +
  1400.         return $this->add($rawPost);
  1401. +
  1402.     }
  1403. +
  1404.  
  1405. +
  1406.     /**
  1407. +
  1408.      * Create an XML fragment from a {@link Apache_Solr_Document} instance appropriate for use inside a Solr add call
  1409. +
  1410.      *
  1411. +
  1412.      * @return string 
  1413. +
  1414.      */
  1415. +
  1416.     protected function _documentToXmlFragment(Apache_Solr_Document $document)
  1417. +
  1418.     {
  1419. +
  1420.         $xml = '<doc>';
  1421. +
  1422.  
  1423. +
  1424.         foreach ($document as $key => $value)
  1425. +
  1426.         {
  1427. +
  1428.             $key = htmlspecialchars($key, ENT_QUOTES, 'UTF-8');
  1429. +
  1430.  
  1431. +
  1432.             if (is_array($value))
  1433. +
  1434.             {
  1435. +
  1436.                 foreach ($value as $multivalue)
  1437. +
  1438.                 {
  1439. +
  1440.                     $multivalue = htmlspecialchars($multivalue, ENT_NOQUOTES, 'UTF-8');
  1441. +
  1442.  
  1443. +
  1444.                     $xml .= '<field name="' . $key . '">' . $multivalue . '</field>';
  1445. +
  1446.                 }
  1447. +
  1448.             }
  1449. +
  1450.             else
  1451. +
  1452.             {
  1453. +
  1454.                 $value = htmlspecialchars($value, ENT_NOQUOTES, 'UTF-8');
  1455. +
  1456.  
  1457. +
  1458.                 $xml .= '<field name="' . $key . '">' . $value . '</field>';
  1459. +
  1460.             }
  1461. +
  1462.         }
  1463. +
  1464.  
  1465. +
  1466.         $xml .= '</doc>';
  1467. +
  1468.  
  1469. +
  1470.         return $xml;
  1471. +
  1472.     }
  1473. +
  1474.  
  1475. +
  1476.     /**
  1477. +
  1478.      * Send a commit command.  Will be synchronous unless both wait parameters are set to false.
  1479. +
  1480.      *
  1481. +
  1482.      * @param boolean $optimize Defaults to true
  1483. +
  1484.      * @param boolean $waitFlush Defaults to true
  1485. +
  1486.      * @param boolean $waitSearcher Defaults to true
  1487. +
  1488.      * @param float $timeout Maximum expected duration (in seconds) of the commit operation on the server (otherwise, will throw a communication exception). Defaults to 1 hour
  1489. +
  1490.      * @return Apache_Solr_Response 
  1491. +
  1492.      *
  1493. +
  1494.      * @throws Exception If an error occurs during the service call
  1495. +
  1496.      */
  1497. +
  1498.     public function commit($optimize = true, $waitFlush = true, $waitSearcher = true, $timeout = 3600)
  1499. +
  1500.     {
  1501. +
  1502.         $optimizeValue = $optimize ? 'true' : 'false';
  1503. +
  1504.         $flushValue = $waitFlush ? 'true' : 'false';
  1505. +
  1506.         $searcherValue = $waitSearcher ? 'true' : 'false';
  1507. +
  1508.  
  1509. +
  1510.         $rawPost = '<commit optimize="' . $optimizeValue . '" waitFlush="' . $flushValue . '" waitSearcher="' . $searcherValue . '" />';
  1511. +
  1512.  
  1513. +
  1514.         return $this->_sendRawPost($this->_updateUrl, $rawPost, $timeout);
  1515. +
  1516.     }
  1517. +
  1518.  
  1519. +
  1520.     /**
  1521. +
  1522.      * Raw Delete Method. Takes a raw post body and sends it to the update service. Body should be
  1523. +
  1524.      * a complete and well formed "delete" xml document
  1525. +
  1526.      *
  1527. +
  1528.      * @param string $rawPost Expected to be utf-8 encoded xml document
  1529. +
  1530.      * @return Apache_Solr_Response 
  1531. +
  1532.      *
  1533. +
  1534.      * @throws Exception If an error occurs during the service call
  1535. +
  1536.      */
  1537. +
  1538.     public function delete($rawPost)
  1539. +
  1540.     {
  1541. +
  1542.         return $this->_sendRawPost($this->_updateUrl, $rawPost);
  1543. +
  1544.     }
  1545. +
  1546.  
  1547. +
  1548.     /**
  1549. +
  1550.      * Create a delete document based on document ID
  1551. +
  1552.      *
  1553. +
  1554.      * @param string $id Expected to be utf-8 encoded
  1555. +
  1556.      * @param boolean $fromPending 
  1557. +
  1558.      * @param boolean $fromCommitted 
  1559. +
  1560.      * @return Apache_Solr_Response 
  1561. +
  1562.      *
  1563. +
  1564.      * @throws Exception If an error occurs during the service call
  1565. +
  1566.      */
  1567. +
  1568.     public function deleteById($id, $fromPending = true, $fromCommitted = true)
  1569. +
  1570.     {
  1571. +
  1572.         $pendingValue = $fromPending ? 'true' : 'false';
  1573. +
  1574.         $committedValue = $fromCommitted ? 'true' : 'false';
  1575. +
  1576.  
  1577. +
  1578.         //escape special xml characters
  1579. +
  1580.         $id = htmlspecialchars($id, ENT_NOQUOTES, 'UTF-8');
  1581. +
  1582.  
  1583. +
  1584.         $rawPost = '<delete fromPending="' . $pendingValue . '" fromCommitted="' . $committedValue . '"><id>' . $id . '</id></delete>';
  1585. +
  1586.  
  1587. +
  1588.         return $this->delete($rawPost);
  1589. +
  1590.     }
  1591. +
  1592.  
  1593. +
  1594.     /**
  1595. +
  1596.      * Create a delete document based on a query and submit it
  1597. +
  1598.      *
  1599. +
  1600.      * @param string $rawQuery Expected to be utf-8 encoded
  1601. +
  1602.      * @param boolean $fromPending 
  1603. +
  1604.      * @param boolean $fromCommitted 
  1605. +
  1606.      * @return Apache_Solr_Response 
  1607. +
  1608.      *
  1609. +
  1610.      * @throws Exception If an error occurs during the service call
  1611. +
  1612.      */
  1613. +
  1614.     public function deleteByQuery($rawQuery, $fromPending = true, $fromCommitted = true)
  1615. +
  1616.     {
  1617. +
  1618.         $pendingValue = $fromPending ? 'true' : 'false';
  1619. +
  1620.         $committedValue = $fromCommitted ? 'true' : 'false';
  1621. +
  1622.  
  1623. +
  1624.         // escape special xml characters
  1625. +
  1626.         $rawQuery = htmlspecialchars($rawQuery, ENT_NOQUOTES, 'UTF-8');
  1627. +
  1628.  
  1629. +
  1630.         $rawPost = '<delete fromPending="' . $pendingValue . '" fromCommitted="' . $committedValue . '"><query>' . $rawQuery . '</query></delete>';
  1631. +
  1632.  
  1633. +
  1634.         return $this->delete($rawPost);
  1635. +
  1636.     }
  1637. +
  1638.  
  1639. +
  1640.     /**
  1641. +
  1642.      * Send an optimize command.  Will be synchronous unless both wait parameters are set
  1643. +
  1644.      * to false.
  1645. +
  1646.      *
  1647. +
  1648.      * @param boolean $waitFlush 
  1649. +
  1650.      * @param boolean $waitSearcher 
  1651. +
  1652.      * @param float $timeout Maximum expected duration of the commit operation on the server (otherwise, will throw a communication exception)
  1653. +
  1654.      * @return Apache_Solr_Response 
  1655. +
  1656.      *
  1657. +
  1658.      * @throws Exception If an error occurs during the service call
  1659. +
  1660.      */
  1661. +
  1662.     public function optimize($waitFlush = true, $waitSearcher = true, $timeout = 3600)
  1663. +
  1664.     {
  1665. +
  1666.         $flushValue = $waitFlush ? 'true' : 'false';
  1667. +
  1668.         $searcherValue = $waitSearcher ? 'true' : 'false';
  1669. +
  1670.  
  1671. +
  1672.         $rawPost = '<optimize waitFlush="' . $flushValue . '" waitSearcher="' . $searcherValue . '" />';
  1673. +
  1674.  
  1675. +
  1676.         return $this->_sendRawPost($this->_updateUrl, $rawPost, $timeout);
  1677. +
  1678.     }
  1679. +
  1680.  
  1681. +
  1682.     /**
  1683. +
  1684.      * Simple Search interface
  1685. +
  1686.      *
  1687. +
  1688.      * @param string $query The raw query string
  1689. +
  1690.      * @param int $offset The starting offset for result documents
  1691. +
  1692.      * @param int $limit The maximum number of result documents to return
  1693. +
  1694.      * @param array $params key / value pairs for other query parameters (see Solr documentation), use arrays for parameter keys used more than once (e.g. facet.field)
  1695. +
  1696.      * @return Apache_Solr_Response 
  1697. +
  1698.      *
  1699. +
  1700.      * @throws Exception If an error occurs during the service call
  1701. +
  1702.      */
  1703. +
  1704.     public function search($query, $offset = 0, $limit = 10, $params = array())
  1705. +
  1706.     {
  1707. +
  1708.         if (!is_array($params))
  1709. +
  1710.         {
  1711. +
  1712.             $params = array();
  1713. +
  1714.         }
  1715. +
  1716.  
  1717. +
  1718.         // construct our full parameters
  1719. +
  1720.         // sending the version is important in case the format changes
  1721. +
  1722.         $params['version'] = self::SOLR_VERSION;
  1723. +
  1724.  
  1725. +
  1726.         // common parameters in this interface
  1727. +
  1728.         $params['wt'] = self::SOLR_WRITER;
  1729. +
  1730.         $params['json.nl'] = $this->_namedListTreatment;
  1731. +
  1732.  
  1733. +
  1734.         $params['q'] = $query;
  1735. +
  1736.         $params['start'] = $offset;
  1737. +
  1738.         $params['rows'] = $limit;
  1739. +
  1740.  
  1741. +
  1742.         // use http_build_query to encode our arguments because its faster
  1743. +
  1744.         // than urlencoding all the parts ourselves in a loop
  1745. +
  1746.         $queryString = http_build_query($params, null, $this->_queryStringDelimiter);
  1747. +
  1748.  
  1749. +
  1750.         // because http_build_query treats arrays differently than we want to, correct the query
  1751. +
  1752.         // string by changing foo[#]=bar (# being an actual number) parameter strings to just
  1753. +
  1754.         // multiple foo=bar strings. This regex should always work since '=' will be urlencoded
  1755. +
  1756.         // anywhere else the regex isn't expecting it
  1757. +
  1758.         $queryString = preg_replace('/%5B(?:[0-9]|[1-9][0-9]+)%5D=/', '=', $queryString);
  1759. +
  1760.  
  1761. +
  1762.         return $this->_sendRawGet($this->_searchUrl . $this->_queryDelimiter . $queryString);
  1763. +
  1764.     }
  1765. +
  1766. }
  1767. +
+
+

+ Documentation generated on Tue, 02 Sep 2008 10:45:05 -0400 by phpDocumentor 1.4.0 +

+ + Index: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_Service_Balancer.html =================================================================== RCS file: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_Service_Balancer.html diff -N sites/all/modules/apachesolr/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_Service_Balancer.html --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sites/all/modules/apachesolr/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_Service_Balancer.html 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,1364 @@ + + + + + + Docs For Class Apache_Solr_Service_Balancer + + + + +
+ +

Class Apache_Solr_Service_Balancer

+ + +
+
Description
+ +
+ +

Reference Implementation for using multiple Solr services in a distribution. Functionality

+

includes: routing of read / write operations failover (on selection) for multiple read servers

+

+ Located in /Service/Balancer.php (line 31) +

+ + +

+	
+			
+
+ + + + +
+
Variable Summary
+ +
+
+
+ mixed + $_backoffEscalation +
+
+ mixed + $_backoffLimit +
+
+ mixed + $_createDocuments +
+
+ mixed + $_currentReadService +
+
+ mixed + $_currentWriteService +
+
+ mixed + $_defaultBackoff +
+
+ mixed + $_readableServices +
+
+ mixed + $_readPingTimeout +
+
+ mixed + $_useBackoff +
+
+ mixed + $_writeableServices +
+
+ mixed + $_writePingTimeout +
+
+
+
+ + +
+
Method Summary
+ +
+
+ +
+ static string + escape + (string $value) +
+ +
+ static string + escapePhrase + (string $value) +
+ +
+ static string + phrase + (string $value) +
+ +
+ Apache_Solr_Service_Balancer + __construct + ([array $readableServices = array()], [array $writeableServices = array()]) +
+ +
+ Apache_Solr_Response + add + (string $rawPost) +
+ +
+ Apache_Solr_Response + addDocument + (Apache_Solr_Document $document, [boolean $allowDups = false], [boolean $overwritePending = true], [boolean $overwriteCommitted = true]) +
+ +
+ Apache_Solr_Response + addDocuments + (array $documents, [boolean $allowDups = false], [boolean $overwritePending = true], [boolean $overwriteCommitted = true]) +
+ +
+ void + addReadService + (mixed $service) +
+ +
+ void + addWriteService + (mixed $service) +
+ +
+ Apache_Solr_Response + commit + ([ $optimize = true], [boolean $waitFlush = true], [boolean $waitSearcher = true], [ $timeout = 3600]) +
+ +
+ Apache_Solr_Response + delete + (string $rawPost) +
+ +
+ Apache_Solr_Response + deleteById + (string $id, [boolean $fromPending = true], [boolean $fromCommitted = true]) +
+ +
+ Apache_Solr_Response + deleteByQuery + (string $rawQuery, [boolean $fromPending = true], [boolean $fromCommitted = true]) +
+ +
+ void + getCreateDocuments + () +
+ +
+ Apache_Solr_Response + optimize + ([boolean $waitFlush = true], [boolean $waitSearcher = true]) +
+ +
+ void + removeReadService + (mixed $service) +
+ +
+ void + removeWriteService + (mixed $service) +
+ +
+ Apache_Solr_Response + search + (string $query, [int $offset = 0], [int $limit = 10], [array $params = array()]) +
+ +
+ void + setCreateDocuments + ( $createDocuments) +
+ +
+ void + setReadPingTimeout + ( $timeout) +
+ +
+ void + setUseBackoff + ( $enable) +
+ +
+ void + setWritePingTimeout + ( $timeout) +
+ +
+ string + _getServiceId + (string $host, integer $port, string $path) +
+ +
+ Apache_Solr_Service + _selectReadService + ([ $forceSelect = false]) +
+ +
+ Apache_Solr_Service + _selectWriteService + ([ $forceSelect = false]) +
+ +
+ Apache_Solr_Service + _selectWriteServiceSafe + ([ $forceSelect = false]) +
+
+
+
+ + +
+
Variables
+ +
+ + +
+ +
+ + mixed + $_backoffEscalation + = 2.0 (line 47) + +
+ + +
    +
  • access: protected
  • +
+ + + + + +
+ +
+ +
+ + mixed + $_backoffLimit + = 600 (line 46) + +
+ + +
    +
  • access: protected
  • +
+ + + + + +
+ +
+ +
+ + mixed + $_createDocuments + = true (line 33) + +
+ + +
    +
  • access: protected
  • +
+ + + + + +
+ +
+ +
+ + mixed + $_currentReadService + = null (line 38) + +
+ + +
    +
  • access: protected
  • +
+ + + + + +
+ +
+ +
+ + mixed + $_currentWriteService + = null (line 39) + +
+ + +
    +
  • access: protected
  • +
+ + + + + +
+ +
+ +
+ + mixed + $_defaultBackoff + = 2.0 (line 48) + +
+ + +
    +
  • access: protected
  • +
+ + + + + +
+ +
+ +
+ + mixed + $_readableServices + = array() (line 35) + +
+ + +
    +
  • access: protected
  • +
+ + + + + +
+ +
+ +
+ + mixed + $_readPingTimeout + = 2 (line 41) + +
+ + +
    +
  • access: protected
  • +
+ + + + + +
+ +
+ +
+ + mixed + $_useBackoff + = false (line 45) + +
+ + +
    +
  • access: protected
  • +
+ + + + + +
+ +
+ +
+ + mixed + $_writeableServices + = array() (line 36) + +
+ + +
    +
  • access: protected
  • +
+ + + + + +
+ +
+ +
+ + mixed + $_writePingTimeout + = 4 (line 42) + +
+ + +
    +
  • access: protected
  • +
+ + + + + +
+ + +
+
+ + +
+
Methods
+ +
+ + +
+ +
+ static escape (line 58) +
+ + +

Escape a value for special query characters such as ':', '(', ')', '*', '?', etc.

+

NOTE: inside a phrase fewer characters need escaped, use Apache_Solr_Service::escapePhrase() instead

+
    +
  • access: public
  • +
+ +
+ static string + + escape + + (string $value) +
+ +
    +
  • + string + $value
  • +
+ + +
+ +
+ +
+ static escapePhrase (line 69) +
+ + +

Escape a value meant to be contained in a phrase for special query characters

+
    +
  • access: public
  • +
+ +
+ static string + + escapePhrase + + (string $value) +
+ +
    +
  • + string + $value
  • +
+ + +
+ +
+ +
+ static phrase (line 80) +
+ + +

Convenience function for creating phrase syntax from a value

+
    +
  • access: public
  • +
+ +
+ static string + + phrase + + (string $value) +
+ +
    +
  • + string + $value
  • +
+ + +
+ +
+ +
+ Constructor __construct (line 91) +
+ + +

Constructor. Takes arrays of read and write service instances or descriptions

+
    +
  • access: public
  • +
+ +
+ Apache_Solr_Service_Balancer + + __construct + + ([array $readableServices = array()], [array $writeableServices = array()]) +
+ +
    +
  • + array + $readableServices
  • +
  • + array + $writeableServices
  • +
+ + +
+ +
+ +
+ add (line 449) +
+ + +

Raw Add Method. Takes a raw post body and sends it to the update service. Post body should be a complete and well formed "add" xml document.

+
    +
  • throws: Exception If an error occurs during the service call
  • +
  • access: public
  • +
+ +
+ Apache_Solr_Response + + add + + (string $rawPost) +
+ +
    +
  • + string + $rawPost
  • +
+ + +
+ +
+ +
+ addDocument (line 484) +
+ + +

Add a Solr Document to the index

+
    +
  • throws: Exception If an error occurs during the service call
  • +
  • access: public
  • +
+ +
+ Apache_Solr_Response + + addDocument + + (Apache_Solr_Document $document, [boolean $allowDups = false], [boolean $overwritePending = true], [boolean $overwriteCommitted = true]) +
+ +
    +
  • + Apache_Solr_Document + $document
  • +
  • + boolean + $allowDups
  • +
  • + boolean + $overwritePending
  • +
  • + boolean + $overwriteCommitted
  • +
+ + +
+ +
+ +
+ addDocuments (line 519) +
+ + +

Add an array of Solr Documents to the index all at once

+
    +
  • throws: Exception If an error occurs during the service call
  • +
  • access: public
  • +
+ +
+ Apache_Solr_Response + + addDocuments + + (array $documents, [boolean $allowDups = false], [boolean $overwritePending = true], [boolean $overwriteCommitted = true]) +
+ +
    +
  • + array + $documents: Should be an array of Apache_Solr_Document instances
  • +
  • + boolean + $allowDups
  • +
  • + boolean + $overwritePending
  • +
  • + boolean + $overwriteCommitted
  • +
+ + +
+ +
+ +
+ addReadService (line 142) +
+ + +

Adds a service instance or service descriptor (if it is already not added)

+
    +
  • throws: Exception If service descriptor is not valid
  • +
  • access: public
  • +
+ +
+ void + + addReadService + + (mixed $service) +
+ +
    +
  • + mixed + $service
  • +
+ + +
+ +
+ +
+ addWriteService (line 210) +
+ + +

Adds a service instance or service descriptor (if it is already not added)

+
    +
  • throws: Exception If service descriptor is not valid
  • +
  • access: public
  • +
+ +
+ void + + addWriteService + + (mixed $service) +
+ +
    +
  • + mixed + $service
  • +
+ + +
+ +
+ +
+ commit (line 553) +
+ + +

Send a commit command. Will be synchronous unless both wait parameters are set to false.

+
    +
  • throws: Exception If an error occurs during the service call
  • +
  • access: public
  • +
+ +
+ Apache_Solr_Response + + commit + + ([ $optimize = true], [boolean $waitFlush = true], [boolean $waitSearcher = true], [ $timeout = 3600]) +
+ +
    +
  • + boolean + $waitFlush
  • +
  • + boolean + $waitSearcher
  • +
  • + + $optimize
  • +
  • + + $timeout
  • +
+ + +
+ +
+ +
+ delete (line 586) +
+ + +

Raw Delete Method. Takes a raw post body and sends it to the update service. Body should be a complete and well formed "delete" xml document

+
    +
  • throws: Exception If an error occurs during the service call
  • +
  • access: public
  • +
+ +
+ Apache_Solr_Response + + delete + + (string $rawPost) +
+ +
    +
  • + string + $rawPost
  • +
+ + +
+ +
+ +
+ deleteById (line 620) +
+ + +

Create a delete document based on document ID

+
    +
  • throws: Exception If an error occurs during the service call
  • +
  • access: public
  • +
+ +
+ Apache_Solr_Response + + deleteById + + (string $id, [boolean $fromPending = true], [boolean $fromCommitted = true]) +
+ +
    +
  • + string + $id
  • +
  • + boolean + $fromPending
  • +
  • + boolean + $fromCommitted
  • +
+ + +
+ +
+ +
+ deleteByQuery (line 654) +
+ + +

Create a delete document based on a query and submit it

+
    +
  • throws: Exception If an error occurs during the service call
  • +
  • access: public
  • +
+ +
+ Apache_Solr_Response + + deleteByQuery + + (string $rawQuery, [boolean $fromPending = true], [boolean $fromCommitted = true]) +
+ +
    +
  • + string + $rawQuery
  • +
  • + boolean + $fromPending
  • +
  • + boolean + $fromCommitted
  • +
+ + +
+ +
+ +
+ getCreateDocuments (line 435) +
+ + +
    +
  • access: public
  • +
+ +
+ void + + getCreateDocuments + + () +
+ + + +
+ +
+ +
+ optimize (line 688) +
+ + +

Send an optimize command. Will be synchronous unless both wait parameters are set to false.

+
    +
  • throws: Exception If an error occurs during the service call
  • +
  • access: public
  • +
+ +
+ Apache_Solr_Response + + optimize + + ([boolean $waitFlush = true], [boolean $waitSearcher = true]) +
+ +
    +
  • + boolean + $waitFlush
  • +
  • + boolean + $waitSearcher
  • +
+ + +
+ +
+ +
+ removeReadService (line 172) +
+ + +

Removes a service instance or descriptor from the available services

+
    +
  • throws: Exception If service descriptor is not valid
  • +
  • access: public
  • +
+ +
+ void + + removeReadService + + (mixed $service) +
+ +
    +
  • + mixed + $service
  • +
+ + +
+ +
+ +
+ removeWriteService (line 240) +
+ + +

Removes a service instance or descriptor from the available services

+
    +
  • throws: Exception If service descriptor is not valid
  • +
  • access: public
  • +
+ +
+ void + + removeWriteService + + (mixed $service) +
+ +
    +
  • + mixed + $service
  • +
+ + +
+ +
+ +
+ search (line 723) +
+ + +

Simple Search interface

+
    +
  • throws: Exception If an error occurs during the service call
  • +
  • access: public
  • +
+ +
+ Apache_Solr_Response + + search + + (string $query, [int $offset = 0], [int $limit = 10], [array $params = array()]) +
+ +
    +
  • + string + $query: The raw query string
  • +
  • + int + $offset: The starting offset for result documents
  • +
  • + int + $limit: The maximum number of result documents to return
  • +
  • + array + $params: key / value pairs for query parameters, use arrays for multivalued parameters
  • +
+ + +
+ +
+ +
+ setCreateDocuments (line 424) +
+ + +
    +
  • access: public
  • +
+ +
+ void + + setCreateDocuments + + ( $createDocuments) +
+ +
    +
  • + + $createDocuments
  • +
+ + +
+ +
+ +
+ setReadPingTimeout (line 106) +
+ + +
    +
  • access: public
  • +
+ +
+ void + + setReadPingTimeout + + ( $timeout) +
+ +
    +
  • + + $timeout
  • +
+ + +
+ +
+ +
+ setUseBackoff (line 116) +
+ + +
    +
  • access: public
  • +
+ +
+ void + + setUseBackoff + + ( $enable) +
+ +
    +
  • + + $enable
  • +
+ + +
+ +
+ +
+ setWritePingTimeout (line 111) +
+ + +
    +
  • access: public
  • +
+ +
+ void + + setWritePingTimeout + + ( $timeout) +
+ +
    +
  • + + $timeout
  • +
+ + +
+ +
+ +
+ _getServiceId (line 129) +
+ + +

Generates a service ID

+
    +
  • access: protected
  • +
+ +
+ string + + _getServiceId + + (string $host, integer $port, string $path) +
+ +
    +
  • + string + $host
  • +
  • + integer + $port
  • +
  • + string + $path
  • +
+ + +
+ +
+ +
+ _selectReadService (line 278) +
+ + +

Iterate through available read services and select the first with a ping that satisfies configured timeout restrictions (or the default)

+
    +
  • throws: Exception If there are no read services that meet requirements
  • +
  • access: protected
  • +
+ +
+ Apache_Solr_Service + + _selectReadService + + ([ $forceSelect = false]) +
+ +
    +
  • + + $forceSelect
  • +
+ + +
+ +
+ +
+ _selectWriteService (line 326) +
+ + +

Iterate through available write services and select the first with a ping that satisfies configured timeout restrictions (or the default)

+
    +
  • throws: Exception If there are no write services that meet requirements
  • +
  • access: protected
  • +
+ +
+ Apache_Solr_Service + + _selectWriteService + + ([ $forceSelect = false]) +
+ +
    +
  • + + $forceSelect
  • +
+ + +
+ +
+ +
+ _selectWriteServiceSafe (line 382) +
+ + +

Iterate through available write services and select the first with a ping

+

that satisfies configured timeout restrictions (or the default). The timeout period will increase until a connection is made or the limit is reached. This will allow for increased reliability with heavily loaded server(s).

+
    +
  • throws: Exception If there are no write services that meet requirements
  • +
  • access: protected
  • +
+ +
+ Apache_Solr_Service + + _selectWriteServiceSafe + + ([ $forceSelect = false]) +
+ +
    +
  • + + $forceSelect
  • +
+ + +
+ +
+
+ + +

+ Documentation generated on Tue, 02 Sep 2008 10:45:03 -0400 by phpDocumentor 1.4.0 +

+
+ Index: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/elementindex.html =================================================================== RCS file: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/elementindex.html diff -N sites/all/modules/apachesolr/SolrPhpClient/phpdocs/elementindex.html --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sites/all/modules/apachesolr/SolrPhpClient/phpdocs/elementindex.html 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,1055 @@ + + + + + + + + + + + + +

Full index

+

Package indexes

+ +
+
+ a + b + c + d + e + g + k + n + o + p + r + s + t + u + v + _ +
+ + +
+
a
+
top
+
+
+
+
+ add +
+
+ +
Raw Add Method. Takes a raw post body and sends it to the update service. Post body should be a complete and well formed "add" xml document.
+
+
+ add +
+
+ +
Raw Add Method. Takes a raw post body and sends it to the update service. Post body should be a complete and well formed "add" xml document.
+
+
+ addDocument +
+
+ +
Add a Solr Document to the index
+
+
+ addDocument +
+
+ +
Add a Solr Document to the index
+
+
+ addDocuments +
+
+ +
Add an array of Solr Documents to the index all at once
+
+
+ addDocuments +
+
+ +
Add an array of Solr Documents to the index all at once
+
+
+ addReadService +
+
+ +
Adds a service instance or service descriptor (if it is already not added)
+
+
+ addWriteService +
+
+ +
Adds a service instance or service descriptor (if it is already not added)
+
+
+ Apache_Solr_Document +
+
+
Apache_Solr_Document in Document.php
+
Holds Key / Value pairs that represent a Solr Document. Field values can be accessed by direct dereferencing such as:
+
+
+ Apache_Solr_Response +
+
+
Apache_Solr_Response in Response.php
+
Represents a Solr response. Parses the raw response into a set of stdClass objects and associative arrays for easy access.
+
+
+ Apache_Solr_Service +
+
+
Apache_Solr_Service in Service.php
+
Starting point for the Solr API. Represents a Solr server resource and has methods for pinging, adding, deleting, committing, optimizing and searching.
+
+
+ Apache_Solr_Service_Balancer +
+
+ +
Reference Implementation for using multiple Solr services in a distribution. Functionality
+
+
+ +
+
b
+
top
+
+
+
+
+ Balancer.php +
+
+
Balancer.php in Balancer.php
+
+
+ +
+
c
+
top
+
+
+
+
+ commit +
+
+ +
Send a commit command. Will be synchronous unless both wait parameters are set to false.
+
+
+ commit +
+
+ +
Send a commit command. Will be synchronous unless both wait parameters are set to false.
+
+
+ current +
+
+ +
Iterator implementation function, proxies to _fields. Allows usage:
+
+
+ +
+
d
+
top
+
+
+
+
+ delete +
+
+ +
Raw Delete Method. Takes a raw post body and sends it to the update service. Body should be a complete and well formed "delete" xml document
+
+
+ delete +
+
+ +
Raw Delete Method. Takes a raw post body and sends it to the update service. Body should be a complete and well formed "delete" xml document
+
+
+ deleteById +
+
+ +
Create a delete document based on document ID
+
+
+ deleteById +
+
+ +
Create a delete document based on document ID
+
+
+ deleteByQuery +
+
+ +
Create a delete document based on a query and submit it
+
+
+ deleteByQuery +
+
+ +
Create a delete document based on a query and submit it
+
+
+ Document.php +
+
+
Document.php in Document.php
+
+
+ +
+
e
+
top
+
+
+
+
+ escape +
+
+ +
Escape a value for special query characters such as ':', '(', ')', '*', '?', etc.
+
+
+ escape +
+
+ +
Escape a value for special query characters such as ':', '(', ')', '*', '?', etc.
+
+
+ escapePhrase +
+
+ +
Escape a value meant to be contained in a phrase for special query characters
+
+
+ escapePhrase +
+
+ +
Escape a value meant to be contained in a phrase for special query characters
+
+
+ +
+
g
+
top
+
+
+
+
+ getCollapseSingleValueArrays +
+
+ +
Get the current state of the collapse single value arrays flag.
+
+
+ getCreateDocuments +
+
+ +
+
+ getCreateDocuments +
+
+ +
Get the current state of teh create documents flag.
+
+
+ getEncoding +
+
+ +
Get character encoding of this response. Should usually be utf-8, but just in case
+
+
+ getFieldNames +
+
+ +
Get the names of all fields in this document
+
+
+ getHost +
+
+ +
Returns the set host
+
+
+ getHttpStatus +
+
+ +
Get the HTTP status code
+
+
+ getHttpStatusMessage +
+
+ +
Get the HTTP status message of the response
+
+
+ getNamedListTreatment +
+
+ +
Get the current setting for named list treatment.
+
+
+ getPath +
+
+ +
Get the set path.
+
+
+ getPort +
+
+ +
Get the set port
+
+
+ getRawResponse +
+
+ +
Get the raw response as it was given to this object
+
+
+ getType +
+
+ +
Get content type of this Solr response
+
+
+ +
+
k
+
top
+
+
+
+
+ key +
+
+ +
Iterator implementation function, proxies to _fields. Allows usage:
+
+
+ +
+
n
+
top
+
+
+
+
+ NAMED_LIST_FLAT +
+
+ +
NamedList Treatment constants
+
+
+ NAMED_LIST_MAP +
+
+ +
+
+ next +
+
+ +
Iterator implementation function, proxies to _fields. Allows usage:
+
+
+ +
+
o
+
top
+
+
+
+
+ optimize +
+
+ +
Send an optimize command. Will be synchronous unless both wait parameters are set to false.
+
+
+ optimize +
+
+ +
Send an optimize command. Will be synchronous unless both wait parameters are set to false.
+
+
+ +
+
p
+
top
+
+
+
+
+ phrase +
+
+ +
Convenience function for creating phrase syntax from a value
+
+
+ phrase +
+
+ +
Convenience function for creating phrase syntax from a value
+
+
+ ping +
+
+ +
Call the /admin/ping servlet, can be used to quickly tell if a connection to the server is able to be made.
+
+
+ PING_SERVLET +
+
+ +
Servlet mappings
+
+
+ +
+
r
+
top
+
+
+
+
+ removeReadService +
+
+ +
Removes a service instance or descriptor from the available services
+
+
+ removeWriteService +
+
+ +
Removes a service instance or descriptor from the available services
+
+
+ Response.php +
+
+
Response.php in Response.php
+
+
+ rewind +
+
+ +
Iterator implementation function, proxies to _fields. Allows usage:
+
+
+ +
+
s
+
top
+
+
+
+
+ search +
+
+ +
Simple Search interface
+
+
+ search +
+
+ +
Simple Search interface
+
+
+ SEARCH_SERVLET +
+
+ +
+
+ Service.php +
+
+
Service.php in Service.php
+
+
+ setCollapseSingleValueArrays +
+
+ +
Set the collapse single value arrays flag.
+
+
+ setCreateDocuments +
+
+ +
Set the create documents flag. This determines whether Apache_Solr_Response objects will parse the response and create Apache_Solr_Document instances in place.
+
+
+ setCreateDocuments +
+
+ +
+
+ setHost +
+
+ +
Set the host used. If empty will fallback to constants
+
+
+ setMultiValue +
+
+ +
Handle the array manipulation for a multi-valued field
+
+
+ setNamedListTreatmet +
+
+ +
Set how NamedLists should be formatted in the response data. This mainly effects the facet counts format.
+
+
+ setPath +
+
+ +
Set the path used. If empty will fallback to constants
+
+
+ setPort +
+
+ +
Set the port used. If empty will fallback to constants
+
+
+ setQueryDelimiter +
+
+ +
Set the string used to separate the path form the query string.
+
+
+ setQueryStringDelimiter +
+
+ +
Set the string used to separate the parameters in thequery string Defaulted to '&'
+
+
+ setReadPingTimeout +
+
+ +
+
+ setUseBackoff +
+
+ +
+
+ setWritePingTimeout +
+
+ +
+
+ SOLR_VERSION +
+
+ +
Response version we support
+
+
+ SOLR_WRITER +
+
+ +
Response writer we support
+
+
+ +
+
t
+
top
+
+
+
+
+ threads +
+
+ +
Call the /admin/threads servlet and retrieve information about all threads in the Solr servlet's thread group. Useful for diagnostics.
+
+
+ THREADS_SERVLET +
+
+ +
+
+ +
+
u
+
top
+
+
+
+
+ UPDATE_SERVLET +
+
+ +
+
+ +
+
v
+
top
+
+
+
+
+ valid +
+
+ +
Iterator implementation function, proxies to _fields. Allows usage:
+
+
+ +
+
_
+
top
+
+
+
+
+ $_backoffEscalation +
+
+ +
+
+ $_backoffLimit +
+
+ +
+
+ $_collapseSingleValueArrays +
+
+ +
+
+ $_collapseSingleValueArrays +
+
+ +
Whether Apache_Solr_Response objects should have multivalue fields with only a single value collapsed to appear as a single value would.
+
+
+ $_createDocuments +
+
+ +
+
+ $_createDocuments +
+
+ +
Data parsing flags. Determines what extra processing should be done after the data is initially converted to a data structure.
+
+
+ $_createDocuments +
+
+ +
Whether Apache_Solr_Response objects should create Apache_Solr_Documents in the returned parsed data
+
+
+ $_currentReadService +
+
+ +
+
+ $_currentWriteService +
+
+ +
+
+ $_defaultBackoff +
+
+ +
+
+ $_encoding +
+
+ +
+
+ $_fields +
+
+ +
+
+ $_host +
+
+ +
Server identification strings
+
+
+ $_httpStatus +
+
+ +
Parsed values from the passed in http headers
+
+
+ $_httpStatusMessage +
+
+ +
+
+ $_isParsed +
+
+ +
Whether the raw response has been parsed
+
+
+ $_namedListTreatment +
+
+ +
How NamedLists should be formatted in the output. This specifically effects facet counts. Valid values are Apache_Solr_Service::NAMED_LIST_MAP (default) or Apache_Solr_Service::NAMED_LIST_FLAT.
+
+
+ $_parsedData +
+
+ +
Parsed representation of the data
+
+
+ $_path +
+
+ +
+
+ $_port +
+
+ +
+
+ $_postContext +
+
+ +
Stream context for posting
+
+
+ $_queryDelimiter +
+
+ +
Query delimiters. Someone might want to be able to change these (to use &amp; instead of & for example), so I've provided them.
+
+
+ $_queryStringDelimiter +
+
+ +
+
+ $_rawResponse +
+
+ +
Holds the raw response used in construction
+
+
+ $_readableServices +
+
+ +
+
+ $_readPingTimeout +
+
+ +
+
+ $_searchUrl +
+
+ +
+
+ $_threadsUrl +
+
+ +
+
+ $_type +
+
+ +
+
+ $_updateUrl +
+
+ +
Constructed servlet full path URLs
+
+
+ $_urlsInited +
+
+ +
Keep track of whether our URLs have been constructed
+
+
+ $_useBackoff +
+
+ +
+
+ $_writeableServices +
+
+ +
+
+ $_writePingTimeout +
+
+ +
+
+ _constructUrl +
+
+ +
Return a valid http URL given this server's host, port and path and a provided servlet name
+
+
+ _documentToXmlFragment +
+
+ +
Create an XML fragment from a Apache_Solr_Document instance appropriate for use inside a Solr add call
+
+
+ _getServiceId +
+
+ +
Generates a service ID
+
+
+ _initUrls +
+
+ +
Construct the Full URLs for the three servlets we reference
+
+
+ _parseData +
+
+ +
Parse the raw response into the parsed_data array for access
+
+
+ _selectReadService +
+
+ +
Iterate through available read services and select the first with a ping that satisfies configured timeout restrictions (or the default)
+
+
+ _selectWriteService +
+
+ +
Iterate through available write services and select the first with a ping that satisfies configured timeout restrictions (or the default)
+
+
+ _selectWriteServiceSafe +
+
+ +
Iterate through available write services and select the first with a ping
+
+
+ _sendRawGet +
+
+ +
Central method for making a get operation against this Solr Server
+
+
+ _sendRawPost +
+
+ +
Central method for making a post operation against this Solr Server
+
+
+ __construct +
+
+ +
Constructor. All parameters are optional and will take on default values if not specified.
+
+
+ __construct +
+
+ +
Constructor. Takes arrays of read and write service instances or descriptions
+
+
+ __construct +
+
+ +
Constructor. Takes the raw HTTP response body and the exploded HTTP headers
+
+
+ __get +
+
+ +
Magic get to expose the parsed data and to lazily load it
+
+
+ __get +
+
+ +
Magic get for field values
+
+
+ __isset +
+
+ +
Magic isset for fields values. Do no call directly. Allows usage:
+
+
+ __set +
+
+ +
Magic set for field values. Multi-valued fields should be set as arrays or instead use the setMultiValue(...) function which will automatically make sure the field is an array.
+
+
+ __unset +
+
+ +
Magic unset for field values. Do no call directly. Allows usage:
+
+
+ +
+ a + b + c + d + e + g + k + n + o + p + r + s + t + u + v + _ +
+ + Index: sites/all/modules/apachesolr/SolrPhpClient/Apache/Solr/Document.php =================================================================== RCS file: sites/all/modules/apachesolr/SolrPhpClient/Apache/Solr/Document.php diff -N sites/all/modules/apachesolr/SolrPhpClient/Apache/Solr/Document.php --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sites/all/modules/apachesolr/SolrPhpClient/Apache/Solr/Document.php 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,199 @@ + + */ + +/** + * Holds Key / Value pairs that represent a Solr Document. Field values can be accessed + * by direct dereferencing such as: + * + * ... + * $document->title = 'Something'; + * echo $document->title; + * ... + * + * + * Additionally, the field values can be iterated with foreach + * + * + * foreach ($document as $key => $value) + * { + * ... + * } + * + */ +class Apache_Solr_Document implements Iterator +{ + protected $_fields = array(); + + /** + * Magic get for field values + * + * @param string $key + * @return mixed + */ + public function __get($key) + { + return $this->_fields[$key]; + } + + /** + * Magic set for field values. Multi-valued fields should be set as arrays + * or instead use the setMultiValue(...) function which will automatically + * make sure the field is an array. + * + * @param string $key + * @param mixed $value + */ + public function __set($key, $value) + { + $this->_fields[$key] = $value; + } + + /** + * Magic isset for fields values. Do no call directly. Allows usage: + * + * + * isset($document->some_field); + * + * + * @param string $key + * @return boolean + */ + public function __isset($key) + { + return isset($this->_fields[$key]); + } + + /** + * Magic unset for field values. Do no call directly. Allows usage: + * + * + * unset($document->some_field); + * + * + * @param string $key + */ + public function __unset($key) + { + unset($this->_fields[$key]); + } + + /** + * Handle the array manipulation for a multi-valued field + * + * @param string $key + * @param string $value + */ + public function setMultiValue($key, $value) + { + if (!isset($this->_fields[$key])) + { + $this->_fields[$key] = array(); + } + + if (!is_array($this->_fields[$key])) + { + $this->_fields[$key] = array($this->_fields[$key]); + } + + $this->_fields[$key][] = $value; + } + + /** + * Get the names of all fields in this document + * + * @return array + */ + public function getFieldNames() + { + return array_keys($this->_fields); + } + + /** + * Iterator implementation function, proxies to _fields. Allows usage: + * + * + * foreach ($document as $key => $value) + * { + * ... + * } + * + */ + public function rewind() { + reset($this->_fields); + } + + /** + * Iterator implementation function, proxies to _fields. Allows usage: + * + * + * foreach ($document as $key => $value) + * { + * ... + * } + * + */ + public function current() { + return current($this->_fields); + } + + /** + * Iterator implementation function, proxies to _fields. Allows usage: + * + * + * foreach ($document as $key => $value) + * { + * ... + * } + * + */ + public function key() { + return key($this->_fields); + } + + /** + * Iterator implementation function, proxies to _fields. Allows usage: + * + * + * foreach ($document as $key => $value) + * { + * ... + * } + * + */ + public function next() { + return next($this->_fields); + } + + /** + * Iterator implementation function, proxies to _fields. Allows usage: + * + * + * foreach ($document as $key => $value) + * { + * ... + * } + * + */ + public function valid() { + return current($this->_fields) !== false; + } +} Index: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/index.html =================================================================== RCS file: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/index.html diff -N sites/all/modules/apachesolr/SolrPhpClient/phpdocs/index.html --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sites/all/modules/apachesolr/SolrPhpClient/phpdocs/index.html 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,24 @@ + + + + + + Generated Documentation + + + + + + + + + + + <H2>Frame Alert</H2> + <P>This document is designed to be viewed using the frames feature. + If you see this message, you are using a non-frame-capable web client.</P> + + + Index: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/elementindex_Apache.html =================================================================== RCS file: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/elementindex_Apache.html diff -N sites/all/modules/apachesolr/SolrPhpClient/phpdocs/elementindex_Apache.html --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sites/all/modules/apachesolr/SolrPhpClient/phpdocs/elementindex_Apache.html 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,1052 @@ + + + + + + + + + + + + +

[Apache] element index

+All elements +
+
+ a + b + c + d + e + g + k + n + o + p + r + s + t + u + v + _ +
+ + +
+
_
+
top
+
+
+
+
+ $_backoffEscalation +
+
+ +
+
+ $_backoffLimit +
+
+ +
+
+ $_collapseSingleValueArrays +
+
+ +
+
+ $_collapseSingleValueArrays +
+
+ +
Whether Apache_Solr_Response objects should have multivalue fields with only a single value collapsed to appear as a single value would.
+
+
+ $_createDocuments +
+
+ +
+
+ $_createDocuments +
+
+ +
Data parsing flags. Determines what extra processing should be done after the data is initially converted to a data structure.
+
+
+ $_createDocuments +
+
+ +
Whether Apache_Solr_Response objects should create Apache_Solr_Documents in the returned parsed data
+
+
+ $_currentReadService +
+
+ +
+
+ $_currentWriteService +
+
+ +
+
+ $_defaultBackoff +
+
+ +
+
+ $_encoding +
+
+ +
+
+ $_fields +
+
+ +
+
+ $_host +
+
+ +
Server identification strings
+
+
+ $_httpStatus +
+
+ +
Parsed values from the passed in http headers
+
+
+ $_httpStatusMessage +
+
+ +
+
+ $_isParsed +
+
+ +
Whether the raw response has been parsed
+
+
+ $_namedListTreatment +
+
+ +
How NamedLists should be formatted in the output. This specifically effects facet counts. Valid values are Apache_Solr_Service::NAMED_LIST_MAP (default) or Apache_Solr_Service::NAMED_LIST_FLAT.
+
+
+ $_parsedData +
+
+ +
Parsed representation of the data
+
+
+ $_path +
+
+ +
+
+ $_port +
+
+ +
+
+ $_postContext +
+
+ +
Stream context for posting
+
+
+ $_queryDelimiter +
+
+ +
Query delimiters. Someone might want to be able to change these (to use &amp; instead of & for example), so I've provided them.
+
+
+ $_queryStringDelimiter +
+
+ +
+
+ $_rawResponse +
+
+ +
Holds the raw response used in construction
+
+
+ $_readableServices +
+
+ +
+
+ $_readPingTimeout +
+
+ +
+
+ $_searchUrl +
+
+ +
+
+ $_threadsUrl +
+
+ +
+
+ $_type +
+
+ +
+
+ $_updateUrl +
+
+ +
Constructed servlet full path URLs
+
+
+ $_urlsInited +
+
+ +
Keep track of whether our URLs have been constructed
+
+
+ $_useBackoff +
+
+ +
+
+ $_writeableServices +
+
+ +
+
+ $_writePingTimeout +
+
+ +
+
+ _constructUrl +
+
+ +
Return a valid http URL given this server's host, port and path and a provided servlet name
+
+
+ _documentToXmlFragment +
+
+ +
Create an XML fragment from a Apache_Solr_Document instance appropriate for use inside a Solr add call
+
+
+ _getServiceId +
+
+ +
Generates a service ID
+
+
+ _initUrls +
+
+ +
Construct the Full URLs for the three servlets we reference
+
+
+ _parseData +
+
+ +
Parse the raw response into the parsed_data array for access
+
+
+ _selectReadService +
+
+ +
Iterate through available read services and select the first with a ping that satisfies configured timeout restrictions (or the default)
+
+
+ _selectWriteService +
+
+ +
Iterate through available write services and select the first with a ping that satisfies configured timeout restrictions (or the default)
+
+
+ _selectWriteServiceSafe +
+
+ +
Iterate through available write services and select the first with a ping
+
+
+ _sendRawGet +
+
+ +
Central method for making a get operation against this Solr Server
+
+
+ _sendRawPost +
+
+ +
Central method for making a post operation against this Solr Server
+
+
+ __construct +
+
+ +
Constructor. All parameters are optional and will take on default values if not specified.
+
+
+ __construct +
+
+ +
Constructor. Takes arrays of read and write service instances or descriptions
+
+
+ __construct +
+
+ +
Constructor. Takes the raw HTTP response body and the exploded HTTP headers
+
+
+ __get +
+
+ +
Magic get to expose the parsed data and to lazily load it
+
+
+ __get +
+
+ +
Magic get for field values
+
+
+ __isset +
+
+ +
Magic isset for fields values. Do no call directly. Allows usage:
+
+
+ __set +
+
+ +
Magic set for field values. Multi-valued fields should be set as arrays or instead use the setMultiValue(...) function which will automatically make sure the field is an array.
+
+
+ __unset +
+
+ +
Magic unset for field values. Do no call directly. Allows usage:
+
+
+ +
+
a
+
top
+
+
+
+
+ add +
+
+ +
Raw Add Method. Takes a raw post body and sends it to the update service. Post body should be a complete and well formed "add" xml document.
+
+
+ add +
+
+ +
Raw Add Method. Takes a raw post body and sends it to the update service. Post body should be a complete and well formed "add" xml document.
+
+
+ addDocument +
+
+ +
Add a Solr Document to the index
+
+
+ addDocument +
+
+ +
Add a Solr Document to the index
+
+
+ addDocuments +
+
+ +
Add an array of Solr Documents to the index all at once
+
+
+ addDocuments +
+
+ +
Add an array of Solr Documents to the index all at once
+
+
+ addReadService +
+
+ +
Adds a service instance or service descriptor (if it is already not added)
+
+
+ addWriteService +
+
+ +
Adds a service instance or service descriptor (if it is already not added)
+
+
+ Apache_Solr_Document +
+
+
Apache_Solr_Document in Document.php
+
Holds Key / Value pairs that represent a Solr Document. Field values can be accessed by direct dereferencing such as:
+
+
+ Apache_Solr_Response +
+
+
Apache_Solr_Response in Response.php
+
Represents a Solr response. Parses the raw response into a set of stdClass objects and associative arrays for easy access.
+
+
+ Apache_Solr_Service +
+
+
Apache_Solr_Service in Service.php
+
Starting point for the Solr API. Represents a Solr server resource and has methods for pinging, adding, deleting, committing, optimizing and searching.
+
+
+ Apache_Solr_Service_Balancer +
+
+ +
Reference Implementation for using multiple Solr services in a distribution. Functionality
+
+
+ +
+
b
+
top
+
+
+
+
+ Balancer.php +
+
+
Balancer.php in Balancer.php
+
+
+ +
+
c
+
top
+
+
+
+
+ commit +
+
+ +
Send a commit command. Will be synchronous unless both wait parameters are set to false.
+
+
+ commit +
+
+ +
Send a commit command. Will be synchronous unless both wait parameters are set to false.
+
+
+ current +
+
+ +
Iterator implementation function, proxies to _fields. Allows usage:
+
+
+ +
+
d
+
top
+
+
+
+
+ delete +
+
+ +
Raw Delete Method. Takes a raw post body and sends it to the update service. Body should be a complete and well formed "delete" xml document
+
+
+ delete +
+
+ +
Raw Delete Method. Takes a raw post body and sends it to the update service. Body should be a complete and well formed "delete" xml document
+
+
+ deleteById +
+
+ +
Create a delete document based on document ID
+
+
+ deleteById +
+
+ +
Create a delete document based on document ID
+
+
+ deleteByQuery +
+
+ +
Create a delete document based on a query and submit it
+
+
+ deleteByQuery +
+
+ +
Create a delete document based on a query and submit it
+
+
+ Document.php +
+
+
Document.php in Document.php
+
+
+ +
+
e
+
top
+
+
+
+
+ escape +
+
+ +
Escape a value for special query characters such as ':', '(', ')', '*', '?', etc.
+
+
+ escape +
+
+ +
Escape a value for special query characters such as ':', '(', ')', '*', '?', etc.
+
+
+ escapePhrase +
+
+ +
Escape a value meant to be contained in a phrase for special query characters
+
+
+ escapePhrase +
+
+ +
Escape a value meant to be contained in a phrase for special query characters
+
+
+ +
+
g
+
top
+
+
+
+
+ getCollapseSingleValueArrays +
+
+ +
Get the current state of the collapse single value arrays flag.
+
+
+ getCreateDocuments +
+
+ +
+
+ getCreateDocuments +
+
+ +
Get the current state of teh create documents flag.
+
+
+ getEncoding +
+
+ +
Get character encoding of this response. Should usually be utf-8, but just in case
+
+
+ getFieldNames +
+
+ +
Get the names of all fields in this document
+
+
+ getHost +
+
+ +
Returns the set host
+
+
+ getHttpStatus +
+
+ +
Get the HTTP status code
+
+
+ getHttpStatusMessage +
+
+ +
Get the HTTP status message of the response
+
+
+ getNamedListTreatment +
+
+ +
Get the current setting for named list treatment.
+
+
+ getPath +
+
+ +
Get the set path.
+
+
+ getPort +
+
+ +
Get the set port
+
+
+ getRawResponse +
+
+ +
Get the raw response as it was given to this object
+
+
+ getType +
+
+ +
Get content type of this Solr response
+
+
+ +
+
k
+
top
+
+
+
+
+ key +
+
+ +
Iterator implementation function, proxies to _fields. Allows usage:
+
+
+ +
+
n
+
top
+
+
+
+
+ NAMED_LIST_FLAT +
+
+ +
NamedList Treatment constants
+
+
+ NAMED_LIST_MAP +
+
+ +
+
+ next +
+
+ +
Iterator implementation function, proxies to _fields. Allows usage:
+
+
+ +
+
o
+
top
+
+
+
+
+ optimize +
+
+ +
Send an optimize command. Will be synchronous unless both wait parameters are set to false.
+
+
+ optimize +
+
+ +
Send an optimize command. Will be synchronous unless both wait parameters are set to false.
+
+
+ +
+
p
+
top
+
+
+
+
+ phrase +
+
+ +
Convenience function for creating phrase syntax from a value
+
+
+ phrase +
+
+ +
Convenience function for creating phrase syntax from a value
+
+
+ ping +
+
+ +
Call the /admin/ping servlet, can be used to quickly tell if a connection to the server is able to be made.
+
+
+ PING_SERVLET +
+
+ +
Servlet mappings
+
+
+ +
+
r
+
top
+
+
+
+
+ removeReadService +
+
+ +
Removes a service instance or descriptor from the available services
+
+
+ removeWriteService +
+
+ +
Removes a service instance or descriptor from the available services
+
+
+ Response.php +
+
+
Response.php in Response.php
+
+
+ rewind +
+
+ +
Iterator implementation function, proxies to _fields. Allows usage:
+
+
+ +
+
s
+
top
+
+
+
+
+ search +
+
+ +
Simple Search interface
+
+
+ search +
+
+ +
Simple Search interface
+
+
+ SEARCH_SERVLET +
+
+ +
+
+ Service.php +
+
+
Service.php in Service.php
+
+
+ setCollapseSingleValueArrays +
+
+ +
Set the collapse single value arrays flag.
+
+
+ setCreateDocuments +
+
+ +
Set the create documents flag. This determines whether Apache_Solr_Response objects will parse the response and create Apache_Solr_Document instances in place.
+
+
+ setCreateDocuments +
+
+ +
+
+ setHost +
+
+ +
Set the host used. If empty will fallback to constants
+
+
+ setMultiValue +
+
+ +
Handle the array manipulation for a multi-valued field
+
+
+ setNamedListTreatmet +
+
+ +
Set how NamedLists should be formatted in the response data. This mainly effects the facet counts format.
+
+
+ setPath +
+
+ +
Set the path used. If empty will fallback to constants
+
+
+ setPort +
+
+ +
Set the port used. If empty will fallback to constants
+
+
+ setQueryDelimiter +
+
+ +
Set the string used to separate the path form the query string.
+
+
+ setQueryStringDelimiter +
+
+ +
Set the string used to separate the parameters in thequery string Defaulted to '&'
+
+
+ setReadPingTimeout +
+
+ +
+
+ setUseBackoff +
+
+ +
+
+ setWritePingTimeout +
+
+ +
+
+ SOLR_VERSION +
+
+ +
Response version we support
+
+
+ SOLR_WRITER +
+
+ +
Response writer we support
+
+
+ +
+
t
+
top
+
+
+
+
+ threads +
+
+ +
Call the /admin/threads servlet and retrieve information about all threads in the Solr servlet's thread group. Useful for diagnostics.
+
+
+ THREADS_SERVLET +
+
+ +
+
+ +
+
u
+
top
+
+
+
+
+ UPDATE_SERVLET +
+
+ +
+
+ +
+
v
+
top
+
+
+
+
+ valid +
+
+ +
Iterator implementation function, proxies to _fields. Allows usage:
+
+
+ +
+ a + b + c + d + e + g + k + n + o + p + r + s + t + u + v + _ +
+ + Index: sites/all/modules/apachesolr/SolrPhpClient/Apache/Solr/Service.php =================================================================== RCS file: sites/all/modules/apachesolr/SolrPhpClient/Apache/Solr/Service.php diff -N sites/all/modules/apachesolr/SolrPhpClient/Apache/Solr/Service.php --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sites/all/modules/apachesolr/SolrPhpClient/Apache/Solr/Service.php 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,886 @@ + + */ + +require_once('Apache/Solr/Document.php'); +require_once('Apache/Solr/Response.php'); + +/** + * Starting point for the Solr API. Represents a Solr server resource and has + * methods for pinging, adding, deleting, committing, optimizing and searching. + * + * Example Usage: + * + * ... + * $solr = new Apache_Solr_Service(); //or explicitly new Apache_Solr_Service('localhost', 8180, '/solr') + * + * if ($solr->ping()) + * { + * $solr->deleteByQuery('*:*'); //deletes ALL documents - be careful :) + * + * $document = new Apache_Solr_Document(); + * $document->id = uniqid(); //or something else suitably unique + * + * $document->title = 'Some Title'; + * $document->content = 'Some content for this wonderful document. Blah blah blah.'; + * + * $solr->addDocument($document); //if you're going to be adding documents in bulk using addDocuments + * //with an array of documents is faster + * + * $solr->commit(); //commit to see the deletes and the document + * $solr->optimize(); //merges multiple segments into one + * + * //and the one we all care about, search! + * //any other common or custom parameters to the request handler can go in the + * //optional 4th array argument. + * $solr->search('content:blah', 0, 10, array('sort' => 'timestamp desc')); + * } + * ... + * + * + * @todo Investigate using other HTTP clients other than file_get_contents built-in handler. Could provide performance + * improvements when dealing with multiple requests by using HTTP's keep alive functionality + */ +class Apache_Solr_Service +{ + /** + * Response version we support + */ + const SOLR_VERSION = '1.2'; + + /** + * Response writer we support + * + * @todo Solr 1.3 release may change this to SerializedPHP or PHP implementation + */ + const SOLR_WRITER = 'json'; + + /** + * NamedList Treatment constants + */ + const NAMED_LIST_FLAT = 'flat'; + const NAMED_LIST_MAP = 'map'; + + /** + * Servlet mappings + */ + const PING_SERVLET = 'admin/ping'; + const UPDATE_SERVLET = 'update'; + const SEARCH_SERVLET = 'select'; + const THREADS_SERVLET = 'admin/threads'; + + /** + * Server identification strings + * + * @var string + */ + protected $_host, $_port, $_path; + + /** + * Whether {@link Apache_Solr_Response} objects should create {@link Apache_Solr_Document}s in + * the returned parsed data + * + * @var boolean + */ + protected $_createDocuments = true; + + /** + * Whether {@link Apache_Solr_Response} objects should have multivalue fields with only a single value + * collapsed to appear as a single value would. + * + * @var boolean + */ + protected $_collapseSingleValueArrays = true; + + /** + * How NamedLists should be formatted in the output. This specifically effects facet counts. Valid values + * are {@link Apache_Solr_Service::NAMED_LIST_MAP} (default) or {@link Apache_Solr_Service::NAMED_LIST_FLAT}. + * + * @var string + */ + protected $_namedListTreatment = self::NAMED_LIST_MAP; + + /** + * Query delimiters. Someone might want to be able to change + * these (to use & instead of & for example), so I've provided them. + * + * @var string + */ + protected $_queryDelimiter = '?', $_queryStringDelimiter = '&'; + + /** + * Constructed servlet full path URLs + * + * @var string + */ + protected $_updateUrl, $_searchUrl, $_threadsUrl; + + /** + * Keep track of whether our URLs have been constructed + * + * @var boolean + */ + protected $_urlsInited = false; + + /** + * Stream context for posting + * + * @var resource + */ + protected $_postContext; + + /** + * Escape a value for special query characters such as ':', '(', ')', '*', '?', etc. + * + * NOTE: inside a phrase fewer characters need escaped, use {@link Apache_Solr_Service::escapePhrase()} instead + * + * @param string $value + * @return string + */ + static public function escape($value) + { + //list taken from http://lucene.apache.org/java/docs/queryparsersyntax.html#Escaping%20Special%20Characters + $pattern = '/(\+|-|&&|\|\||!|\(|\)|\{|}|\[|]|\^|"|~|\*|\?|:|\\\)/'; + $replace = '\\\$1'; + + return preg_replace($pattern, $replace, $value); + } + + /** + * Escape a value meant to be contained in a phrase for special query characters + * + * @param string $value + * @return string + */ + static public function escapePhrase($value) + { + $pattern = '/("|\\\)/'; + $replace = '\\\$1'; + + return preg_replace($pattern, $replace, $value); + } + + /** + * Convenience function for creating phrase syntax from a value + * + * @param string $value + * @return string + */ + static public function phrase($value) + { + return '"' . self::escapePhrase($value) . '"'; + } + + /** + * Constructor. All parameters are optional and will take on default values + * if not specified. + * + * @param string $host + * @param string $port + * @param string $path + */ + public function __construct($host = 'localhost', $port = 8180, $path = '/solr/') + { + $this->setHost($host); + $this->setPort($port); + $this->setPath($path); + + $this->_initUrls(); + + //set up the stream context for posting with file_get_contents + $contextOpts = array( + 'http' => array( + 'method' => 'POST', + 'header' => "Content-Type: text/xml; charset=UTF-8\r\n" //php.net example showed \r\n at the end + ) + ); + + $this->_postContext = stream_context_create($contextOpts); + } + + /** + * Return a valid http URL given this server's host, port and path and a provided servlet name + * + * @param string $servlet + * @return string + */ + protected function _constructUrl($servlet, $params = array()) + { + if (count($params)) + { + //escape all parameters appropriately for inclusion in the query string + $escapedParams = array(); + + foreach ($params as $key => $value) + { + $escapedParams[] = urlencode($key) . '=' . urlencode($value); + } + + $queryString = $this->_queryDelimiter . implode($this->_queryStringDelimiter, $escapedParams); + } + else + { + $queryString = ''; + } + + return 'http://' . $this->_host . ':' . $this->_port . $this->_path . $servlet . $queryString; + } + + /** + * Construct the Full URLs for the three servlets we reference + */ + protected function _initUrls() + { + //Initialize our full servlet URLs now that we have server information + $this->_updateUrl = $this->_constructUrl(self::UPDATE_SERVLET, array('wt' => self::SOLR_WRITER )); + $this->_searchUrl = $this->_constructUrl(self::SEARCH_SERVLET); + $this->_threadsUrl = $this->_constructUrl(self::THREADS_SERVLET, array('wt' => self::SOLR_WRITER )); + + $this->_urlsInited = true; + } + + /** + * Central method for making a get operation against this Solr Server + * + * @param string $url + * @param float $timeout Read timeout in seconds + * @return Apache_Solr_Response + * + * @todo implement timeout ability + * @throws Exception If a non 200 response status is returned + */ + protected function _sendRawGet($url, $timeout = FALSE) + { + //$http_response_header is set by file_get_contents + $response = new Apache_Solr_Response(@file_get_contents($url), $http_response_header, $this->_createDocuments, $this->_collapseSingleValueArrays); + + if ($response->getHttpStatus() != 200) + { + throw new Exception('"' . $response->getHttpStatus() . '" Status: ' . $response->getHttpStatusMessage(), $response->getHttpStatus()); + } + + return $response; + } + + /** + * Central method for making a post operation against this Solr Server + * + * @param string $url + * @param string $rawPost + * @param float $timeout Read timeout in seconds + * @param string $contentType + * @return Apache_Solr_Response + * + * @throws Exception If a non 200 response status is returned + */ + protected function _sendRawPost($url, $rawPost, $timeout = FALSE, $contentType = 'text/xml; charset=UTF-8') + { + //ensure content type is correct + stream_context_set_option($this->_postContext, 'http', 'header', 'Content-Type: ' . $contentType); + + //set the read timeout if specified + if ($timeout !== FALSE) + { + stream_context_set_option($this->_postContext, 'http', 'timeout', $timeout); + } + + //set the content + stream_context_set_option($this->_postContext, 'http', 'content', $rawPost); + + //$http_response_header is set by file_get_contents + $response = new Apache_Solr_Response(@file_get_contents($url, false, $this->_postContext), $http_response_header, $this->_createDocuments, $this->_collapseSingleValueArrays); + + if ($response->getHttpStatus() != 200) + { + throw new Exception('"' . $response->getHttpStatus() . '" Status: ' . $response->getHttpStatusMessage(), $response->getHttpStatus()); + } + + return $response; + } + + /** + * Returns the set host + * + * @return string + */ + public function getHost() + { + return $this->_host; + } + + /** + * Set the host used. If empty will fallback to constants + * + * @param string $host + */ + public function setHost($host) + { + //Use the provided host or use the default + if (empty($host)) + { + throw new Exception('Host parameter is empty'); + } + else + { + $this->_host = $host; + } + + if ($this->_urlsInited) + { + $this->_initUrls(); + } + } + + /** + * Get the set port + * + * @return integer + */ + public function getPort() + { + return $this->_port; + } + + /** + * Set the port used. If empty will fallback to constants + * + * @param integer $port + */ + public function setPort($port) + { + //Use the provided port or use the default + $port = (int) $port; + + if ($port <= 0) + { + throw new Exception('Port is not a valid port number'); + } + else + { + $this->_port = $port; + } + + if ($this->_urlsInited) + { + $this->_initUrls(); + } + } + + /** + * Get the set path. + * + * @return string + */ + public function getPath() + { + return $this->_path; + } + + /** + * Set the path used. If empty will fallback to constants + * + * @param string $path + */ + public function setPath($path) + { + $path = trim($path, '/'); + + $this->_path = '/' . $path . '/'; + + if ($this->_urlsInited) + { + $this->_initUrls(); + } + } + + /** + * Set the create documents flag. This determines whether {@link Apache_Solr_Response} objects will + * parse the response and create {@link Apache_Solr_Document} instances in place. + * + * @param unknown_type $createDocuments + */ + public function setCreateDocuments($createDocuments) + { + $this->_createDocuments = (bool) $createDocuments; + } + + /** + * Get the current state of teh create documents flag. + * + * @return boolean + */ + public function getCreateDocuments() + { + return $this->_createDocuments; + } + + /** + * Set the collapse single value arrays flag. + * + * @param boolean $collapseSingleValueArrays + */ + public function setCollapseSingleValueArrays($collapseSingleValueArrays) + { + $this->_collapseSingleValueArrays = (bool) $collapseSingleValueArrays; + } + + /** + * Get the current state of the collapse single value arrays flag. + * + * @return boolean + */ + public function getCollapseSingleValueArrays() + { + return $this->_collapseSingleValueArrays; + } + + /** + * Set how NamedLists should be formatted in the response data. This mainly effects + * the facet counts format. + * + * @param string $namedListTreatment + * @throws Exception If invalid option is set + */ + public function setNamedListTreatmet($namedListTreatment) + { + switch ((string) $namedListTreatment) + { + case Apache_Solr_Service::NAMED_LIST_FLAT: + $this->_namedListTreatment = Apache_Solr_Service::NAMED_LIST_FLAT; + break; + + case Apache_Solr_Service::NAMED_LIST_MAP: + $this->_namedListTreatment = Apache_Solr_Service::NAMED_LIST_MAP; + break; + + default: + throw new Exception('Not a valid named list treatement option'); + } + } + + /** + * Get the current setting for named list treatment. + * + * @return string + */ + public function getNamedListTreatment() + { + return $this->_namedListTreatment; + } + + + /** + * Set the string used to separate the path form the query string. + * Defaulted to '?' + * + * @param string $queryDelimiter + */ + public function setQueryDelimiter($queryDelimiter) + { + $this->_queryDelimiter = $queryDelimiter; + } + + /** + * Set the string used to separate the parameters in thequery string + * Defaulted to '&' + * + * @param string $queryStringDelimiter + */ + public function setQueryStringDelimiter($queryStringDelimiter) + { + $this->_queryStringDelimiter = $queryStringDelimiter; + } + + /** + * Call the /admin/ping servlet, can be used to quickly tell if a connection to the + * server is able to be made. + * + * @param float $timeout maximum time to wait for ping in seconds, -1 for unlimited (default is 2) + * @return float Actual time taken to ping the server, FALSE if timeout occurs + */ + public function ping($timeout = 2) + { + $timeout = (float) $timeout; + + if ($timeout <= 0) + { + $timeout = -1; + } + + $start = microtime(true); + + //to prevent strict errors + $errno = 0; + $errstr = ''; + + //try to connect to the host with timeout + $fp = fsockopen($this->_host, $this->_port, $errno, $errstr, $timeout); + + if ($fp) + { + //If we have a timeout set, then determine the amount of time we have left + //in the request and set the stream timeout for the write operation + if ($timeout > 0) + { + //do the calculation + $writeTimeout = $timeout - (microtime(true) - $start); + + //check if we're out of time + if ($writeTimeout <= 0) + { + fclose($fp); + return false; + } + + //convert to microseconds and set the stream timeout + $writeTimeoutInMicroseconds = (int) $writeTimeout * 1000000; + stream_set_timeout($fp, 0, $writeTimeoutInMicroseconds); + } + + $request = 'HEAD ' . $this->_path . self::PING_SERVLET . ' HTTP/1.1' . "\r\n" . + 'host: ' . $this->_host . "\r\n" . + 'Connection: close' . "\r\n" . + "\r\n"; + + fwrite($fp, $request); + + //check the stream meta data to see if we timed out during the operation + $metaData = stream_get_meta_data($fp); + + if (isset($metaData['timeout']) && $metaData['timeout']) + { + fclose($fp); + return false; + } + + + //if we have a timeout set and have made it this far, determine the amount of time + //still remaining and set the timeout appropriately before the read operation + if ($timeout > 0) + { + //do the calculation + $readTimeout = $timeout - (microtime(true) - $start); + + //check if we've run out of time + if ($readTimeout <= 0) + { + fclose($fp); + return false; + } + + //convert to microseconds and set the stream timeout + $readTimeoutInMicroseconds = $readTimeout * 1000000; + stream_set_timeout($fp, 0, $readTimeoutInMicroseconds); + } + + //at the very least we should get a response header line of + //HTTP/1.1 200 OK + $response = fread($fp, 15); + + //check the stream meta data to see if we timed out during the operation + $metaData = stream_get_meta_data($fp); + fclose($fp); //we're done with the connection - ignore the rest + + if (isset($metaData['timeout']) && $metaData['timeout']) + { + return false; + } + + //finally, check the response header line + if ($response != 'HTTP/1.1 200 OK') + { + return false; + } + + //we made it, return the approximate ping time + return microtime(true) - $start; + } + + //we weren't able to make a connection + return false; + } + + /** + * Call the /admin/threads servlet and retrieve information about all threads in the + * Solr servlet's thread group. Useful for diagnostics. + * + * @return Apache_Solr_Response + * + * @throws Exception If an error occurs during the service call + */ + public function threads() + { + return $this->_sendRawGet($this->_threadsUrl); + } + + /** + * Raw Add Method. Takes a raw post body and sends it to the update service. Post body + * should be a complete and well formed "add" xml document. + * + * @param string $rawPost + * @return Apache_Solr_Response + * + * @throws Exception If an error occurs during the service call + */ + public function add($rawPost) + { + return $this->_sendRawPost($this->_updateUrl, $rawPost); + } + + /** + * Add a Solr Document to the index + * + * @param Apache_Solr_Document $document + * @param boolean $allowDups + * @param boolean $overwritePending + * @param boolean $overwriteCommitted + * @return Apache_Solr_Response + * + * @throws Exception If an error occurs during the service call + */ + public function addDocument(Apache_Solr_Document $document, $allowDups = false, $overwritePending = true, $overwriteCommitted = true) + { + $dupValue = $allowDups ? 'true' : 'false'; + $pendingValue = $overwritePending ? 'true' : 'false'; + $committedValue = $overwriteCommitted ? 'true' : 'false'; + + $rawPost = ''; + $rawPost .= $this->_documentToXmlFragment($document); + $rawPost .= ''; + + return $this->add($rawPost); + } + + /** + * Add an array of Solr Documents to the index all at once + * + * @param array $documents Should be an array of Apache_Solr_Document instances + * @param boolean $allowDups + * @param boolean $overwritePending + * @param boolean $overwriteCommitted + * @return Apache_Solr_Response + * + * @throws Exception If an error occurs during the service call + */ + public function addDocuments($documents, $allowDups = false, $overwritePending = true, $overwriteCommitted = true) + { + $dupValue = $allowDups ? 'true' : 'false'; + $pendingValue = $overwritePending ? 'true' : 'false'; + $committedValue = $overwriteCommitted ? 'true' : 'false'; + + $rawPost = ''; + + foreach ($documents as $document) + { + if ($document instanceof Apache_Solr_Document) + { + $rawPost .= $this->_documentToXmlFragment($document); + } + } + + $rawPost .= ''; + + return $this->add($rawPost); + } + + /** + * Create an XML fragment from a {@link Apache_Solr_Document} instance appropriate for use inside a Solr add call + * + * @return string + */ + protected function _documentToXmlFragment(Apache_Solr_Document $document) + { + $xml = ''; + + foreach ($document as $key => $value) + { + $key = htmlspecialchars($key, ENT_QUOTES, 'UTF-8'); + + if (is_array($value)) + { + foreach ($value as $multivalue) + { + $multivalue = htmlspecialchars($multivalue, ENT_NOQUOTES, 'UTF-8'); + + $xml .= '' . $multivalue . ''; + } + } + else + { + $value = htmlspecialchars($value, ENT_NOQUOTES, 'UTF-8'); + + $xml .= '' . $value . ''; + } + } + + $xml .= ''; + + return $xml; + } + + /** + * Send a commit command. Will be synchronous unless both wait parameters are set to false. + * + * @param boolean $optimize Defaults to true + * @param boolean $waitFlush Defaults to true + * @param boolean $waitSearcher Defaults to true + * @param float $timeout Maximum expected duration (in seconds) of the commit operation on the server (otherwise, will throw a communication exception). Defaults to 1 hour + * @return Apache_Solr_Response + * + * @throws Exception If an error occurs during the service call + */ + public function commit($optimize = true, $waitFlush = true, $waitSearcher = true, $timeout = 3600) + { + $optimizeValue = $optimize ? 'true' : 'false'; + $flushValue = $waitFlush ? 'true' : 'false'; + $searcherValue = $waitSearcher ? 'true' : 'false'; + + $rawPost = ''; + + return $this->_sendRawPost($this->_updateUrl, $rawPost, $timeout); + } + + /** + * Raw Delete Method. Takes a raw post body and sends it to the update service. Body should be + * a complete and well formed "delete" xml document + * + * @param string $rawPost Expected to be utf-8 encoded xml document + * @return Apache_Solr_Response + * + * @throws Exception If an error occurs during the service call + */ + public function delete($rawPost) + { + return $this->_sendRawPost($this->_updateUrl, $rawPost); + } + + /** + * Create a delete document based on document ID + * + * @param string $id Expected to be utf-8 encoded + * @param boolean $fromPending + * @param boolean $fromCommitted + * @return Apache_Solr_Response + * + * @throws Exception If an error occurs during the service call + */ + public function deleteById($id, $fromPending = true, $fromCommitted = true) + { + $pendingValue = $fromPending ? 'true' : 'false'; + $committedValue = $fromCommitted ? 'true' : 'false'; + + //escape special xml characters + $id = htmlspecialchars($id, ENT_NOQUOTES, 'UTF-8'); + + $rawPost = '' . $id . ''; + + return $this->delete($rawPost); + } + + /** + * Create a delete document based on a query and submit it + * + * @param string $rawQuery Expected to be utf-8 encoded + * @param boolean $fromPending + * @param boolean $fromCommitted + * @return Apache_Solr_Response + * + * @throws Exception If an error occurs during the service call + */ + public function deleteByQuery($rawQuery, $fromPending = true, $fromCommitted = true) + { + $pendingValue = $fromPending ? 'true' : 'false'; + $committedValue = $fromCommitted ? 'true' : 'false'; + + // escape special xml characters + $rawQuery = htmlspecialchars($rawQuery, ENT_NOQUOTES, 'UTF-8'); + + $rawPost = '' . $rawQuery . ''; + + return $this->delete($rawPost); + } + + /** + * Send an optimize command. Will be synchronous unless both wait parameters are set + * to false. + * + * @param boolean $waitFlush + * @param boolean $waitSearcher + * @param float $timeout Maximum expected duration of the commit operation on the server (otherwise, will throw a communication exception) + * @return Apache_Solr_Response + * + * @throws Exception If an error occurs during the service call + */ + public function optimize($waitFlush = true, $waitSearcher = true, $timeout = 3600) + { + $flushValue = $waitFlush ? 'true' : 'false'; + $searcherValue = $waitSearcher ? 'true' : 'false'; + + $rawPost = ''; + + return $this->_sendRawPost($this->_updateUrl, $rawPost, $timeout); + } + + /** + * Simple Search interface + * + * @param string $query The raw query string + * @param int $offset The starting offset for result documents + * @param int $limit The maximum number of result documents to return + * @param array $params key / value pairs for other query parameters (see Solr documentation), use arrays for parameter keys used more than once (e.g. facet.field) + * @return Apache_Solr_Response + * + * @throws Exception If an error occurs during the service call + */ + public function search($query, $offset = 0, $limit = 10, $params = array(), $search_servlet = null) + { + if (!is_array($params)) + { + $params = array(); + } + + // construct our full parameters + // sending the version is important in case the format changes + $params['version'] = self::SOLR_VERSION; + + // common parameters in this interface + $params['wt'] = self::SOLR_WRITER; + $params['json.nl'] = $this->_namedListTreatment; + + $params['q'] = $query; + $params['start'] = $offset; + $params['rows'] = $limit; + + // use http_build_query to encode our arguments because its faster + // than urlencoding all the parts ourselves in a loop + $queryString = http_build_query($params, null, $this->_queryStringDelimiter); + + // because http_build_query treats arrays differently than we want to, correct the query + // string by changing foo[#]=bar (# being an actual number) parameter strings to just + // multiple foo=bar strings. This regex should always work since '=' will be urlencoded + // anywhere else the regex isn't expecting it + $queryString = preg_replace('/%5B(?:[0-9]|[1-9][0-9]+)%5D=/', '=', $queryString); + + //Enable different search request handlers + $searchUrl = $search_servlet==null ? $this->_searchUrl : $this->_constructUrl($search_servlet); + return $this->_sendRawGet($searchUrl . $this->_queryDelimiter . $queryString); + } +} Index: sites/all/modules/apachesolr/SolrPhpClient/ChangeLog =================================================================== RCS file: sites/all/modules/apachesolr/SolrPhpClient/ChangeLog diff -N sites/all/modules/apachesolr/SolrPhpClient/ChangeLog --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sites/all/modules/apachesolr/SolrPhpClient/ChangeLog 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,113 @@ +2008-08-26 14:50 dwolfe + + * Apache/Solr/Service/Balancer.php: Changed default value for + $_backoffLimit to 10 minutes instead of 1 minute. + +2008-08-26 13:52 dwolfe + + * Apache/Solr/Service/Balancer.php, Solr.clss: Added an increasing + backoff interval for SOLR write server selection. See core ticket + #274. + +2008-05-01 05:52 djimenez + + * Apache/Solr/Service/Balancer.php: Looking at the load balanced + solr's on production it became obvious it was completely silly to + ping a solr service on selection. Instead, we select a read + service at random (if there are more than one) and use it until + there is a connection problem - then and ONLY then do we ping it + to decide if we should retry the call. If the ping timesout then + we select another read service (if one is available) and continue + +2008-04-11 20:46 djimenez + + * Apache/Solr/Service/Balancer.php: doubled timeouts on balancer so + I'll see less exceptions during high load + +2008-01-26 01:03 djimenez + + * Apache/Solr/Response.php: HTTP 100 Continue response can also be + returned before the REAL status header, so instead of just + looking at the first http header we should look through until the + last one. + + the spec for ref.: + http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.1 + + Thanks to Daniel Andersson for pointing out this oversight - + again, probably related to his build's used of libcurl for URL + wrappers + +2008-01-26 00:48 djimenez + + * Apache/Solr/Service.php: \r\n added to the end Content-Type + header was causing problems when compiled with the + --with-curlwrappers options. It had always seemed wrong to me, + but the documentation wasn't explicit as to whether it was added + directly to the headers or not. + + THANKS TO Daniel Andersson for finding this bug, since our php + build is not compiled with this options and we never would have + found it ourselves. + +2008-01-14 19:12 djimenez + + * Apache/Solr/Response.php, Apache/Solr/Service.php, Solr.clss: + Using the json.nl parameter instead of mapping namedLists with my + own code. Added getters / setters for optional enhancements. + +2007-10-19 16:42 djimenez + + * Apache/Solr/Response.php, Apache/Solr/Service.php: Added extra + options to Apache_Solr_Response to allow the turning off of + special "corrections" we do to the json response. In cases where + this isn't needed OR isn't desired it can be a small speed boost. + Changed the implementation of Apache_Solr_Service::search to use + http_build_query - had to combine it with a preg_replace, but + this is still significantly faster than doing all the urlencoding + ourselves in a loop written in PHP. + +2007-10-17 15:14 djimenez + + * Apache/Solr/Document.php, Apache/Solr/Response.php, + Apache/Solr/Service.php, Apache/Solr/Service/Balancer.php: Added + ability to keep Response object from creating documents (can save + a little time when you don't need them). Also, updated the + balancer so that it will try other services during a + communication error on a call. + +2007-10-02 16:54 djimenez + + * Apache/Solr/Response.php: Missed changing the package / + subpackage pair. refs #29 + +2007-10-02 02:52 djimenez + + * Apache/Solr/Service.php: Got rid of the const defined defaults + for host, port and path. Now defined within the constructor + signature so its easier to override in a subclass + +2007-09-28 22:40 djimenez + + * Apache/Solr/Document.php, Apache/Solr/Response.php, + Apache/Solr/Service, Apache/Solr/Service.php, + Apache/Solr/Service/Balancer.php, + trunk/application/cit5_solr/start.inc: Add the + Apache_Solr_Service_Balancer ref. implementation for selecting + from multiple read or write solr instances (such as in a + replicated solr environment). Made the ping function of Service + more useful and faster. stopped ignoring when we couldn't talk to + a server (now throws a communication error exception). refs #29 + +2007-09-24 22:17 djimenez + + * Apache, Apache/Solr, Apache/Solr/Document.php, + Apache/Solr/Response.php, Apache/Solr/Service.php, + Solr/Document.php, Solr/Response.php, Solr/Service.php, + trunk/application/cit5_solr/start.inc: been suggested by + community to change class namespace to Apache_Solr... have kept + subclasses for backwards compatibility with code we have already + + need config constants for now + + closes #10, #16 Index: sites/all/modules/apachesolr/SolrPhpClient/Apache/Solr/Response.php =================================================================== RCS file: sites/all/modules/apachesolr/SolrPhpClient/Apache/Solr/Response.php diff -N sites/all/modules/apachesolr/SolrPhpClient/Apache/Solr/Response.php --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sites/all/modules/apachesolr/SolrPhpClient/Apache/Solr/Response.php 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,264 @@ + + */ + +/** + * Represents a Solr response. Parses the raw response into a set of stdClass objects + * and associative arrays for easy access. + * + * Currently requires json_decode which is bundled with PHP >= 5.2.0, Alternatively can be + * installed with PECL. Zend Framework also includes a purely PHP solution. + * + * @todo When Solr 1.3 is released, possibly convert to use PHP or Serialized PHP output writer + */ +class Apache_Solr_Response +{ + /** + * Holds the raw response used in construction + * + * @var string + */ + protected $_rawResponse; + + /** + * Parsed values from the passed in http headers + * + * @var string + */ + protected $_httpStatus, $_httpStatusMessage, $_type, $_encoding; + + /** + * Whether the raw response has been parsed + * + * @var boolean + */ + protected $_isParsed = false; + + /** + * Parsed representation of the data + * + * @var mixed + */ + protected $_parsedData; + + /** + * Data parsing flags. Determines what extra processing should be done + * after the data is initially converted to a data structure. + * + * @var boolean + */ + protected $_createDocuments = true, + $_collapseSingleValueArrays = true; + + /** + * Constructor. Takes the raw HTTP response body and the exploded HTTP headers + * + * @param string $rawResponse + * @param array $httpHeaders + * @param boolean $createDocuments Whether to convert the documents json_decoded as stdClass instances to Apache_Solr_Document instances + * @param boolean $collapseSingleValueArrays Whether to make multivalued fields appear as single values + */ + public function __construct($rawResponse, $httpHeaders = array(), $createDocuments = true, $collapseSingleValueArrays = true) + { + //Assume 0, 'Communication Error', utf-8, and text/plain + $status = 0; + $statusMessage = 'Communication Error'; + $type = 'text/plain'; + $encoding = 'UTF-8'; + + //iterate through headers for real status, type, and encoding + if (is_array($httpHeaders) && count($httpHeaders) > 0) + { + //look at the first headers for the HTTP status code + //and message (errors are usually returned this way) + // + //HTTP 100 Continue response can also be returned before + //the REAL status header, so we need look until we find + //the last header starting with HTTP + // + //the spec: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.1 + // + //Thanks to Daniel Andersson for pointing out this oversight + while (isset($httpHeaders[0]) && substr($httpHeaders[0], 0, 4) == 'HTTP') + { + $parts = split(' ', substr($httpHeaders[0], 9), 2); + + $status = $parts[0]; + $statusMessage = trim($parts[1]); + + array_shift($httpHeaders); + } + + //Look for the Content-Type response header and determine type + //and encoding from it (if possible - such as 'Content-Type: text/plain; charset=UTF-8') + foreach ($httpHeaders as $header) + { + if (strncasecmp($header, 'Content-Type:', 13) == 0) + { + //split content type value into two parts if possible + $parts = split(';', substr($header, 13), 2); + + $type = trim($parts[0]); + + if ($parts[1]) + { + //split the encoding section again to get the value + $parts = split('=', $parts[1], 2); + + if ($parts[1]) + { + $encoding = trim($parts[1]); + } + } + + break; + } + } + } + + $this->_rawResponse = $rawResponse; + $this->_type = $type; + $this->_encoding = $encoding; + $this->_httpStatus = $status; + $this->_httpStatusMessage = $statusMessage; + $this->_createDocuments = (bool) $createDocuments; + $this->_collapseSingleValueArrays = (bool) $collapseSingleValueArrays; + } + + /** + * Get the HTTP status code + * + * @return integer + */ + public function getHttpStatus() + { + return $this->_httpStatus; + } + + /** + * Get the HTTP status message of the response + * + * @return string + */ + public function getHttpStatusMessage() + { + return $this->_httpStatusMessage; + } + + /** + * Get content type of this Solr response + * + * @return string + */ + public function getType() + { + return $this->_type; + } + + /** + * Get character encoding of this response. Should usually be utf-8, but just in case + * + * @return string + */ + public function getEncoding() + { + return $this->_encoding; + } + + /** + * Get the raw response as it was given to this object + * + * @return string + */ + public function getRawResponse() + { + return $this->_rawResponse; + } + + /** + * Magic get to expose the parsed data and to lazily load it + * + * @param unknown_type $key + * @return unknown + */ + public function __get($key) + { + if (!$this->_isParsed) + { + $this->_parseData(); + $this->_isParsed = true; + } + + if (isset($this->_parsedData->$key)) + { + return $this->_parsedData->$key; + } + + return null; + } + + /** + * Parse the raw response into the parsed_data array for access + */ + protected function _parseData() + { + //An alternative would be to use Zend_Json::decode(...) + $data = json_decode($this->_rawResponse); + + //if we're configured to collapse single valued arrays or to convert them to Apache_Solr_Document objects + //and we have response documents, then try to collapse the values and / or convert them now + if (($this->_createDocuments || $this->_collapseSingleValueArrays) && isset($data->response) && is_array($data->response->docs)) + { + $documents = array(); + + foreach ($data->response->docs as $originalDocument) + { + if ($this->_createDocuments) + { + $document = new Apache_Solr_Document(); + } + else + { + $document = $originalDocument; + } + + foreach ($originalDocument as $key => $value) + { + //If a result is an array with only a single + //value then its nice to be able to access + //it as if it were always a single value + if ($this->_collapseSingleValueArrays && is_array($value) && count($value) <= 1) + { + $value = array_shift($value); + } + + $document->$key = $value; + } + + $documents[] = $document; + } + + $data->response->docs = $documents; + } + + $this->_parsedData = $data; + } +} Index: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/Apache/Solr/_Service---Balancer.php.html =================================================================== RCS file: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/Apache/Solr/_Service---Balancer.php.html diff -N sites/all/modules/apachesolr/SolrPhpClient/phpdocs/Apache/Solr/_Service---Balancer.php.html --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sites/all/modules/apachesolr/SolrPhpClient/phpdocs/Apache/Solr/_Service---Balancer.php.html 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,94 @@ + + + + + + Docs for page Balancer.php + + + + +
+ +

/Service/Balancer.php

+ + +
+
Description
+ +
+ + + +
+
+ + +
+
Classes
+ +
+ + + + + + + + + +
ClassDescription
+ Apache_Solr_Service_Balancer + + Reference Implementation for using multiple Solr services in a distribution. Functionality +
+
+
+ + +
+
Includes
+ +
+ +
+ +
+ + require_once + ('Apache/Solr/Service.php') + (line 23) + +
+ + + +
+
+
+ + + + +

+ Documentation generated on Tue, 02 Sep 2008 10:45:03 -0400 by phpDocumentor 1.4.0 +

+
+ Index: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/todolist.html =================================================================== RCS file: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/todolist.html diff -N sites/all/modules/apachesolr/SolrPhpClient/phpdocs/todolist.html --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sites/all/modules/apachesolr/SolrPhpClient/phpdocs/todolist.html 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,34 @@ + + + + + + Todo List + + + + + +

Todo List

+

Apache

+

Apache_Solr_Response

+ +

Apache_Solr_Service

+ +

Apache_Solr_Service::SOLR_WRITER

+ +

Apache_Solr_Service::_sendRawGet()

+ +

+ Documentation generated on Tue, 02 Sep 2008 10:45:05 -0400 by phpDocumentor 1.4.0 +

+ + Index: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/Apache/Solr/_Service.php.html =================================================================== RCS file: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/Apache/Solr/_Service.php.html diff -N sites/all/modules/apachesolr/SolrPhpClient/phpdocs/Apache/Solr/_Service.php.html --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sites/all/modules/apachesolr/SolrPhpClient/phpdocs/Apache/Solr/_Service.php.html 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,108 @@ + + + + + + Docs for page Service.php + + + + +
+ +

/Service.php

+ + +
+
Description
+ +
+ + + +
+
+ + +
+
Classes
+ +
+ + + + + + + + + +
ClassDescription
+ Apache_Solr_Service + + Starting point for the Solr API. Represents a Solr server resource and has methods for pinging, adding, deleting, committing, optimizing and searching. +
+
+
+ + +
+
Includes
+ +
+ +
+ +
+ + require_once + ('Apache/Solr/Document.php') + (line 23) + +
+ + + +
+ +
+ +
+ + require_once + ('Apache/Solr/Response.php') + (line 24) + +
+ + + +
+
+
+ + + + +

+ Documentation generated on Tue, 02 Sep 2008 10:45:04 -0400 by phpDocumentor 1.4.0 +

+
+ Index: sites/all/modules/apachesolr/SolrPhpClient/NOTICE =================================================================== RCS file: sites/all/modules/apachesolr/SolrPhpClient/NOTICE diff -N sites/all/modules/apachesolr/SolrPhpClient/NOTICE --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sites/all/modules/apachesolr/SolrPhpClient/NOTICE 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,7 @@ +============================================================== + Solr PHP Client + Copyright 2007 Conduit Internet Technologies, Inc +============================================================== + +This product includes software developed by +Conduit Internet Technologies, Inc. (http://conduit-it.com) Index: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/packages.html =================================================================== RCS file: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/packages.html diff -N sites/all/modules/apachesolr/SolrPhpClient/phpdocs/packages.html --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sites/all/modules/apachesolr/SolrPhpClient/phpdocs/packages.html 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + Index: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/li_Apache.html =================================================================== RCS file: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/li_Apache.html diff -N sites/all/modules/apachesolr/SolrPhpClient/phpdocs/li_Apache.html --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sites/all/modules/apachesolr/SolrPhpClient/phpdocs/li_Apache.html 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,51 @@ + + + + + + + + + + + +
Apache
+ +

phpDocumentor v 1.4.0

+ + Index: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_Response.php.html =================================================================== RCS file: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_Response.php.html diff -N sites/all/modules/apachesolr/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_Response.php.html --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sites/all/modules/apachesolr/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_Response.php.html 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,285 @@ + + + + + + File Source for Response.php + + + + + +

Source for file Response.php

+

Documentation is available at Response.php

+
+
  1. <?php
  2. +
  3. /**
  4. +
  5.  * @copyright Copyright 2007 Conduit Internet Technologies, Inc. (http://conduit-it.com)
  6. +
  7.  * @license Apache Licence, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
  8. +
  9.  *
  10. +
  11.  *  Licensed under the Apache License, Version 2.0 (the "License");
  12. +
  13.  *  you may not use this file except in compliance with the License.
  14. +
  15.  *  You may obtain a copy of the License at
  16. +
  17.  *
  18. +
  19.  *      http://www.apache.org/licenses/LICENSE-2.0
  20. +
  21.  *
  22. +
  23.  *  Unless required by applicable law or agreed to in writing, software
  24. +
  25.  *  distributed under the License is distributed on an "AS IS" BASIS,
  26. +
  27.  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  28. +
  29.  *  See the License for the specific language governing permissions and
  30. +
  31.  *  limitations under the License.
  32. +
  33.  *
  34. +
  35.  * @package Apache
  36. +
  37.  * @subpackage Solr
  38. +
  39.  * @author Donovan Jimenez <djimenez@conduit-it.com>
  40. +
  41.  */
  42. +
  43.  
  44. +
  45. /**
  46. +
  47.  * Represents a Solr response.  Parses the raw response into a set of stdClass objects
  48. +
  49.  * and associative arrays for easy access.
  50. +
  51.  *
  52. +
  53.  * Currently requires json_decode which is bundled with PHP >= 5.2.0, Alternatively can be
  54. +
  55.  * installed with PECL.  Zend Framework also includes a purely PHP solution.
  56. +
  57.  *
  58. +
  59.  * @todo When Solr 1.3 is released, possibly convert to use PHP or Serialized PHP output writer
  60. +
  61.  */
  62. +
  63. +
  64. {
  65. +
  66.     /**
  67. +
  68.      * Holds the raw response used in construction
  69. +
  70.      *
  71. +
  72.      * @var string 
  73. +
  74.      */
  75. +
  76.     protected $_rawResponse;
  77. +
  78.  
  79. +
  80.     /**
  81. +
  82.      * Parsed values from the passed in http headers
  83. +
  84.      *
  85. +
  86.      * @var string 
  87. +
  88.      */
  89. +
  90. +
  91.  
  92. +
  93.     /**
  94. +
  95.      * Whether the raw response has been parsed
  96. +
  97.      *
  98. +
  99.      * @var boolean 
  100. +
  101.      */
  102. +
  103.     protected $_isParsed = false;
  104. +
  105.  
  106. +
  107.     /**
  108. +
  109.      * Parsed representation of the data
  110. +
  111.      *
  112. +
  113.      * @var mixed 
  114. +
  115.      */
  116. +
  117.     protected $_parsedData;
  118. +
  119.  
  120. +
  121.     /**
  122. +
  123.      * Data parsing flags.  Determines what extra processing should be done
  124. +
  125.      * after the data is initially converted to a data structure.
  126. +
  127.      *
  128. +
  129.      * @var boolean 
  130. +
  131.      */
  132. +
  133.     protected $_createDocuments = true,
  134. +
  135.             $_collapseSingleValueArrays = true;
  136. +
  137.  
  138. +
  139.     /**
  140. +
  141.      * Constructor. Takes the raw HTTP response body and the exploded HTTP headers
  142. +
  143.      *
  144. +
  145.      * @param string $rawResponse 
  146. +
  147.      * @param array $httpHeaders 
  148. +
  149.      * @param boolean $createDocuments Whether to convert the documents json_decoded as stdClass instances to Apache_Solr_Document instances
  150. +
  151.      * @param boolean $collapseSingleValueArrays Whether to make multivalued fields appear as single values
  152. +
  153.      */
  154. +
  155.     public function __construct($rawResponse, $httpHeaders = array(), $createDocuments = true, $collapseSingleValueArrays = true)
  156. +
  157.     {
  158. +
  159.         //Assume 0, 'Communication Error', utf-8, and  text/plain
  160. +
  161.         $status = 0;
  162. +
  163.         $statusMessage = 'Communication Error';
  164. +
  165.         $type = 'text/plain';
  166. +
  167.         $encoding = 'UTF-8';
  168. +
  169.  
  170. +
  171.         //iterate through headers for real status, type, and encoding
  172. +
  173.         if (is_array($httpHeaders) && count($httpHeaders) > 0)
  174. +
  175.         {
  176. +
  177.             //look at the first headers for the HTTP status code
  178. +
  179.             //and message (errors are usually returned this way)
  180. +
  181.             //
  182. +
  183.             //HTTP 100 Continue response can also be returned before
  184. +
  185.             //the REAL status header, so we need look until we find
  186. +
  187.             //the last header starting with HTTP
  188. +
  189.             //
  190. +
  191.             //the spec: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.1
  192. +
  193.             //
  194. +
  195.             //Thanks to Daniel Andersson for pointing out this oversight
  196. +
  197.             while (isset($httpHeaders[0]) && substr($httpHeaders[0], 0, 4) == 'HTTP')
  198. +
  199.             {
  200. +
  201.                 $parts = split(' ', substr($httpHeaders[0], 9), 2);
  202. +
  203.  
  204. +
  205.                 $status = $parts[0];
  206. +
  207.                 $statusMessage = trim($parts[1]);
  208. +
  209.  
  210. +
  211.                 array_shift($httpHeaders);
  212. +
  213.             }
  214. +
  215.  
  216. +
  217.             //Look for the Content-Type response header and determine type
  218. +
  219.             //and encoding from it (if possible - such as 'Content-Type: text/plain; charset=UTF-8')
  220. +
  221.             foreach ($httpHeaders as $header)
  222. +
  223.             {
  224. +
  225.                 if (strncasecmp($header, 'Content-Type:', 13) == 0)
  226. +
  227.                 {
  228. +
  229.                     //split content type value into two parts if possible
  230. +
  231.                     $parts = split(';', substr($header, 13), 2);
  232. +
  233.  
  234. +
  235.                     $type = trim($parts[0]);
  236. +
  237.  
  238. +
  239.                     if ($parts[1])
  240. +
  241.                     {
  242. +
  243.                         //split the encoding section again to get the value
  244. +
  245.                         $parts = split('=', $parts[1], 2);
  246. +
  247.  
  248. +
  249.                         if ($parts[1])
  250. +
  251.                         {
  252. +
  253.                             $encoding = trim($parts[1]);
  254. +
  255.                         }
  256. +
  257.                     }
  258. +
  259.  
  260. +
  261.                     break;
  262. +
  263.                 }
  264. +
  265.             }
  266. +
  267.         }
  268. +
  269.  
  270. +
  271.         $this->_rawResponse = $rawResponse;
  272. +
  273.         $this->_type = $type;
  274. +
  275.         $this->_encoding = $encoding;
  276. +
  277.         $this->_httpStatus = $status;
  278. +
  279.         $this->_httpStatusMessage = $statusMessage;
  280. +
  281.         $this->_createDocuments = (bool) $createDocuments;
  282. +
  283.         $this->_collapseSingleValueArrays = (bool) $collapseSingleValueArrays;
  284. +
  285.     }
  286. +
  287.  
  288. +
  289.     /**
  290. +
  291.      * Get the HTTP status code
  292. +
  293.      *
  294. +
  295.      * @return integer 
  296. +
  297.      */
  298. +
  299.     public function getHttpStatus()
  300. +
  301.     {
  302. +
  303.         return $this->_httpStatus;
  304. +
  305.     }
  306. +
  307.  
  308. +
  309.     /**
  310. +
  311.      * Get the HTTP status message of the response
  312. +
  313.      *
  314. +
  315.      * @return string 
  316. +
  317.      */
  318. +
  319.     public function getHttpStatusMessage()
  320. +
  321.     {
  322. +
  323.         return $this->_httpStatusMessage;
  324. +
  325.     }
  326. +
  327.  
  328. +
  329.     /**
  330. +
  331.      * Get content type of this Solr response
  332. +
  333.      *
  334. +
  335.      * @return string 
  336. +
  337.      */
  338. +
  339.     public function getType()
  340. +
  341.     {
  342. +
  343.         return $this->_type;
  344. +
  345.     }
  346. +
  347.  
  348. +
  349.     /**
  350. +
  351.      * Get character encoding of this response. Should usually be utf-8, but just in case
  352. +
  353.      *
  354. +
  355.      * @return string 
  356. +
  357.      */
  358. +
  359.     public function getEncoding()
  360. +
  361.     {
  362. +
  363.         return $this->_encoding;
  364. +
  365.     }
  366. +
  367.  
  368. +
  369.     /**
  370. +
  371.      * Get the raw response as it was given to this object
  372. +
  373.      *
  374. +
  375.      * @return string 
  376. +
  377.      */
  378. +
  379.     public function getRawResponse()
  380. +
  381.     {
  382. +
  383.         return $this->_rawResponse;
  384. +
  385.     }
  386. +
  387.  
  388. +
  389.     /**
  390. +
  391.      * Magic get to expose the parsed data and to lazily load it
  392. +
  393.      *
  394. +
  395.      * @param unknown_type $key 
  396. +
  397.      * @return unknown 
  398. +
  399.      */
  400. +
  401.     public function __get($key)
  402. +
  403.     {
  404. +
  405.         if (!$this->_isParsed)
  406. +
  407.         {
  408. +
  409.             $this->_parseData();
  410. +
  411.             $this->_isParsed = true;
  412. +
  413.         }
  414. +
  415.  
  416. +
  417.         if (isset($this->_parsedData->$key))
  418. +
  419.         {
  420. +
  421.             return $this->_parsedData->$key;
  422. +
  423.         }
  424. +
  425.  
  426. +
  427.         return null;
  428. +
  429.     }
  430. +
  431.  
  432. +
  433.     /**
  434. +
  435.      * Parse the raw response into the parsed_data array for access
  436. +
  437.      */
  438. +
  439.     protected function _parseData()
  440. +
  441.     {
  442. +
  443.         //An alternative would be to use Zend_Json::decode(...)
  444. +
  445.         $data = json_decode($this->_rawResponse);
  446. +
  447.  
  448. +
  449.         //if we're configured to collapse single valued arrays or to convert them to Apache_Solr_Document objects
  450. +
  451.         //and we have response documents, then try to collapse the values and / or convert them now
  452. +
  453.         if (($this->_createDocuments || $this->_collapseSingleValueArrays) && isset($data->response) && is_array($data->response->docs))
  454. +
  455.         {
  456. +
  457.             $documents = array();
  458. +
  459.  
  460. +
  461.             foreach ($data->response->docs as $originalDocument)
  462. +
  463.             {
  464. +
  465.                 if ($this->_createDocuments)
  466. +
  467.                 {
  468. +
  469.                     $document = new Apache_Solr_Document();
  470. +
  471.                 }
  472. +
  473.                 else
  474. +
  475.                 {
  476. +
  477.                     $document = $originalDocument;
  478. +
  479.                 }
  480. +
  481.  
  482. +
  483.                 foreach ($originalDocument as $key => $value)
  484. +
  485.                 {
  486. +
  487.                     //If a result is an array with only a single
  488. +
  489.                     //value then its nice to be able to access
  490. +
  491.                     //it as if it were always a single value
  492. +
  493.                     if ($this->_collapseSingleValueArrays && is_array($value) && count($value) <= 1)
  494. +
  495.                     {
  496. +
  497.                         $value = array_shift($value);
  498. +
  499.                     }
  500. +
  501.  
  502. +
  503.                     $document->$key = $value;
  504. +
  505.                 }
  506. +
  507.  
  508. +
  509.                 $documents[] = $document;
  510. +
  511.             }
  512. +
  513.  
  514. +
  515.             $data->response->docs = $documents;
  516. +
  517.         }
  518. +
  519.  
  520. +
  521.         $this->_parsedData = $data;
  522. +
  523.     }
  524. +
  525. }
  526. +
+
+

+ Documentation generated on Tue, 02 Sep 2008 10:45:04 -0400 by phpDocumentor 1.4.0 +

+ + Index: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/errors.html =================================================================== RCS file: sites/all/modules/apachesolr/SolrPhpClient/phpdocs/errors.html diff -N sites/all/modules/apachesolr/SolrPhpClient/phpdocs/errors.html --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ sites/all/modules/apachesolr/SolrPhpClient/phpdocs/errors.html 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,40 @@ + + + + + + phpDocumentor Parser Errors and Warnings + + + + + +Post-parsing
+Document.php
+Response.php
+Service.php
+ +

Balancer.php

+

Warnings:


+Warning on line 22 - Page-level DocBlock precedes "require_once 'Apache/Solr/Service.php'", use another DocBlock to document the source element
+Warning on line 31 - no @package tag was used in a DocBlock for class Apache_Solr_Service_Balancer
+ +

Document.php

+

Warnings:


+Warning on line 42 - no @package tag was used in a DocBlock for class Apache_Solr_Document
+

Errors:


+Error on line 41 - Unclosed code tag in DocBlock, parsing will be incorrect
+ +

Response.php

+

Warnings:


+Warning on line 32 - no @package tag was used in a DocBlock for class Apache_Solr_Response
+ +

Service.php

+

Warnings:


+Warning on line 22 - Page-level DocBlock precedes "require_once 'Apache/Solr/Document.php'", use another DocBlock to document the source element
+Warning on line 62 - no @package tag was used in a DocBlock for class Apache_Solr_Service
+

+ Documentation generated on Tue, 02 Sep 2008 10:45:05 -0400 by phpDocumentor 1.4.0 +

+ +