From d8237ffb999af1ddc5dcbf0413d5f1f9b93fc330 Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Thu, 26 Sep 2013 16:23:17 +0200 Subject: [PATCH] updated to 1.2 --- CHANGELOG.txt | 64 + INSTALL.txt | 93 +- README.txt | 53 +- SolrPhpClient/Apache/Solr/Document.php | 367 --- SolrPhpClient/Apache/Solr/Exception.php | 50 - .../Apache/Solr/HttpTransport/Abstract.php | 89 - .../Apache/Solr/HttpTransport/Curl.php | 198 -- .../Apache/Solr/HttpTransport/CurlNoReuse.php | 196 -- .../Solr/HttpTransport/FileGetContents.php | 216 -- .../Apache/Solr/HttpTransport/Interface.php | 94 - .../Apache/Solr/HttpTransport/Response.php | 255 -- .../Apache/Solr/HttpTransportException.php | 79 - .../Apache/Solr/InvalidArgumentException.php | 50 - .../Solr/NoServiceAvailableException.php | 50 - SolrPhpClient/Apache/Solr/ParserException.php | 50 - SolrPhpClient/Apache/Solr/Response.php | 247 -- SolrPhpClient/Apache/Solr/Service.php | 1181 -------- .../Apache/Solr/Service/Balancer.php | 914 ------ SolrPhpClient/COPYING | 26 - SolrPhpClient/ChangeLog | 342 --- .../Apache/Solr/Apache_Solr_Document.html | 901 ------ .../Apache/Solr/Apache_Solr_Exception.html | 269 -- .../Apache_Solr_HttpTransportException.html | 246 -- .../Apache_Solr_HttpTransport_Abstract.html | 196 -- .../Solr/Apache_Solr_HttpTransport_Curl.html | 336 --- ...Apache_Solr_HttpTransport_CurlNoReuse.html | 279 -- ...he_Solr_HttpTransport_FileGetContents.html | 309 -- .../Apache_Solr_HttpTransport_Interface.html | 260 -- .../Apache_Solr_HttpTransport_Response.html | 298 -- .../Apache_Solr_InvalidArgumentException.html | 144 - ...ache_Solr_NoServiceAvailableException.html | 144 - .../Solr/Apache_Solr_ParserException.html | 144 - .../Apache/Solr/Apache_Solr_Response.html | 621 ----- .../Apache/Solr/Apache_Solr_Service.html | 2473 ----------------- .../Solr/Apache_Solr_Service_Balancer.html | 1606 ----------- .../phpdocs/Apache/Solr/_Document.php.html | 74 - .../phpdocs/Apache/Solr/_Exception.php.html | 63 - .../Solr/_HttpTransport---Abstract.php.html | 74 - .../Solr/_HttpTransport---Curl.php.html | 101 - .../_HttpTransport---CurlNoReuse.php.html | 101 - .../_HttpTransport---FileGetContents.php.html | 101 - .../Solr/_HttpTransport---Interface.php.html | 101 - .../Solr/_HttpTransport---Response.php.html | 74 - .../Solr/_HttpTransportException.php.html | 63 - .../Solr/_InvalidArgumentException.php.html | 63 - .../_NoServiceAvailableException.php.html | 63 - .../Apache/Solr/_ParserException.php.html | 63 - .../phpdocs/Apache/Solr/_Response.php.html | 101 - .../Apache/Solr/_Service---Balancer.php.html | 115 - .../phpdocs/Apache/Solr/_Service.php.html | 171 -- .../fsource_Apache_Solr_Document.php.html | 387 --- .../fsource_Apache_Solr_Exception.php.html | 70 - ...Apache_Solr_HttpTransportAbstract.php.html | 109 - ...rce_Apache_Solr_HttpTransportCurl.php.html | 218 -- ...che_Solr_HttpTransportCurlNoReuse.php.html | 216 -- ...pache_Solr_HttpTransportException.php.html | 99 - ...Solr_HttpTransportFileGetContents.php.html | 236 -- ...pache_Solr_HttpTransportInterface.php.html | 114 - ...Apache_Solr_HttpTransportResponse.php.html | 275 -- ...che_Solr_InvalidArgumentException.php.html | 70 - ..._Solr_NoServiceAvailableException.php.html | 70 - ...ource_Apache_Solr_ParserException.php.html | 70 - .../fsource_Apache_Solr_Response.php.html | 267 -- .../fsource_Apache_Solr_Service.php.html | 1201 -------- ...ource_Apache_Solr_ServiceBalancer.php.html | 934 ------- SolrPhpClient/phpdocs/blank.html | 13 - SolrPhpClient/phpdocs/classtrees_Apache.html | 56 - SolrPhpClient/phpdocs/elementindex.html | 1726 ------------ .../phpdocs/elementindex_Apache.html | 1723 ------------ SolrPhpClient/phpdocs/errors.html | 95 - SolrPhpClient/phpdocs/index.html | 24 - SolrPhpClient/phpdocs/li_Apache.html | 72 - SolrPhpClient/phpdocs/media/banner.css | 32 - SolrPhpClient/phpdocs/media/stylesheet.css | 142 - SolrPhpClient/phpdocs/packages.html | 29 - SolrPhpClient/phpdocs/todolist.html | 29 - .../tests/Apache/Solr/DocumentTest.php | 439 --- .../Solr/HttpTransport/AbstractTest.php | 208 -- .../Solr/HttpTransport/CurlNoReuseTest.php | 53 - .../Apache/Solr/HttpTransport/CurlTest.php | 53 - .../HttpTransport/FileGetContentsTest.php | 53 - .../Solr/HttpTransport/ResponseTest.php | 164 -- .../Solr/HttpTransportExceptionTest.php | 58 - .../tests/Apache/Solr/ResponseTest.php | 194 -- .../Apache/Solr/Service/BalancerTest.php | 47 - .../tests/Apache/Solr/ServiceAbstractTest.php | 139 - .../tests/Apache/Solr/ServiceTest.php | 1119 -------- SolrPhpClient/tests/README | 20 - SolrPhpClient/tests/phpunit.bootstrap.inc | 28 - SolrPhpClient/tests/phpunit.xml | 15 - SolrPhpClient/tests/run.php | 42 - includes/document.inc | 435 +++ service.inc => includes/service.inc | 1045 ++++--- includes/solr_connection.inc | 901 ++++++ includes/solr_connection.interface.inc | 365 +++ solr_field.inc => includes/solr_field.inc | 116 +- includes/solr_httptransport.inc | 100 - includes/spellcheck.inc | 8 +- search_api_solr.admin.inc | 62 + search_api_solr.api.php | 90 +- search_api_solr.info | 15 +- search_api_solr.install | 86 +- search_api_solr.module | 259 +- solr-conf/1.4/elevate.xml | 31 + solr-conf/1.4/mapping-ISOLatin1Accent.txt | 14 + solr-conf/1.4/schema.xml | 22 +- solr-conf/1.4/schema_extra_fields.xml | 23 + solr-conf/1.4/schema_extra_types.xml | 30 + solr-conf/1.4/solrconfig.xml | 127 +- solr-conf/1.4/solrconfig_extra.xml | 80 + solr-conf/1.4/solrcore.properties | 18 +- solr-conf/1.4/stopwords.txt | 4 + solr-conf/1.4/synonyms.txt | 3 + solr-conf/3.x/elevate.xml | 31 + solr-conf/3.x/mapping-ISOLatin1Accent.txt | 14 + solr-conf/3.x/schema.xml | 22 +- solr-conf/3.x/schema_extra_fields.xml | 23 + solr-conf/3.x/schema_extra_types.xml | 30 + solr-conf/3.x/solrconfig.xml | 126 +- solr-conf/3.x/solrconfig_extra.xml | 80 + solr-conf/3.x/solrcore.properties | 22 +- solr-conf/3.x/stopwords.txt | 4 + solr-conf/3.x/synonyms.txt | 3 + solr-conf/4.x/elevate.xml | 31 + solr-conf/4.x/mapping-ISOLatin1Accent.txt | 14 + solr-conf/4.x/protwords.txt | 7 + solr-conf/4.x/schema.xml | 547 ++++ solr-conf/4.x/schema_extra_fields.xml | 23 + solr-conf/4.x/schema_extra_types.xml | 30 + solr-conf/4.x/solrconfig.xml | 1603 +++++++++++ solr-conf/4.x/solrconfig_extra.xml | 80 + solr-conf/4.x/solrcore.properties | 12 + solr-conf/4.x/stopwords.txt | 4 + solr-conf/4.x/synonyms.txt | 3 + solr_connection.inc | 259 -- 135 files changed, 5808 insertions(+), 26071 deletions(-) delete mode 100644 SolrPhpClient/Apache/Solr/Document.php delete mode 100644 SolrPhpClient/Apache/Solr/Exception.php delete mode 100644 SolrPhpClient/Apache/Solr/HttpTransport/Abstract.php delete mode 100644 SolrPhpClient/Apache/Solr/HttpTransport/Curl.php delete mode 100644 SolrPhpClient/Apache/Solr/HttpTransport/CurlNoReuse.php delete mode 100644 SolrPhpClient/Apache/Solr/HttpTransport/FileGetContents.php delete mode 100644 SolrPhpClient/Apache/Solr/HttpTransport/Interface.php delete mode 100644 SolrPhpClient/Apache/Solr/HttpTransport/Response.php delete mode 100644 SolrPhpClient/Apache/Solr/HttpTransportException.php delete mode 100644 SolrPhpClient/Apache/Solr/InvalidArgumentException.php delete mode 100644 SolrPhpClient/Apache/Solr/NoServiceAvailableException.php delete mode 100644 SolrPhpClient/Apache/Solr/ParserException.php delete mode 100644 SolrPhpClient/Apache/Solr/Response.php delete mode 100644 SolrPhpClient/Apache/Solr/Service.php delete mode 100644 SolrPhpClient/Apache/Solr/Service/Balancer.php delete mode 100644 SolrPhpClient/COPYING delete mode 100644 SolrPhpClient/ChangeLog delete mode 100644 SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_Document.html delete mode 100644 SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_Exception.html delete mode 100644 SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_HttpTransportException.html delete mode 100644 SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_HttpTransport_Abstract.html delete mode 100644 SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_HttpTransport_Curl.html delete mode 100644 SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_HttpTransport_CurlNoReuse.html delete mode 100644 SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_HttpTransport_FileGetContents.html delete mode 100644 SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_HttpTransport_Interface.html delete mode 100644 SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_HttpTransport_Response.html delete mode 100644 SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_InvalidArgumentException.html delete mode 100644 SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_NoServiceAvailableException.html delete mode 100644 SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_ParserException.html delete mode 100644 SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_Response.html delete mode 100644 SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_Service.html delete mode 100644 SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_Service_Balancer.html delete mode 100644 SolrPhpClient/phpdocs/Apache/Solr/_Document.php.html delete mode 100644 SolrPhpClient/phpdocs/Apache/Solr/_Exception.php.html delete mode 100644 SolrPhpClient/phpdocs/Apache/Solr/_HttpTransport---Abstract.php.html delete mode 100644 SolrPhpClient/phpdocs/Apache/Solr/_HttpTransport---Curl.php.html delete mode 100644 SolrPhpClient/phpdocs/Apache/Solr/_HttpTransport---CurlNoReuse.php.html delete mode 100644 SolrPhpClient/phpdocs/Apache/Solr/_HttpTransport---FileGetContents.php.html delete mode 100644 SolrPhpClient/phpdocs/Apache/Solr/_HttpTransport---Interface.php.html delete mode 100644 SolrPhpClient/phpdocs/Apache/Solr/_HttpTransport---Response.php.html delete mode 100644 SolrPhpClient/phpdocs/Apache/Solr/_HttpTransportException.php.html delete mode 100644 SolrPhpClient/phpdocs/Apache/Solr/_InvalidArgumentException.php.html delete mode 100644 SolrPhpClient/phpdocs/Apache/Solr/_NoServiceAvailableException.php.html delete mode 100644 SolrPhpClient/phpdocs/Apache/Solr/_ParserException.php.html delete mode 100644 SolrPhpClient/phpdocs/Apache/Solr/_Response.php.html delete mode 100644 SolrPhpClient/phpdocs/Apache/Solr/_Service---Balancer.php.html delete mode 100644 SolrPhpClient/phpdocs/Apache/Solr/_Service.php.html delete mode 100644 SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_Document.php.html delete mode 100644 SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_Exception.php.html delete mode 100644 SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_HttpTransportAbstract.php.html delete mode 100644 SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_HttpTransportCurl.php.html delete mode 100644 SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_HttpTransportCurlNoReuse.php.html delete mode 100644 SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_HttpTransportException.php.html delete mode 100644 SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_HttpTransportFileGetContents.php.html delete mode 100644 SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_HttpTransportInterface.php.html delete mode 100644 SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_HttpTransportResponse.php.html delete mode 100644 SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_InvalidArgumentException.php.html delete mode 100644 SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_NoServiceAvailableException.php.html delete mode 100644 SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_ParserException.php.html delete mode 100644 SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_Response.php.html delete mode 100644 SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_Service.php.html delete mode 100644 SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_ServiceBalancer.php.html delete mode 100644 SolrPhpClient/phpdocs/blank.html delete mode 100644 SolrPhpClient/phpdocs/classtrees_Apache.html delete mode 100644 SolrPhpClient/phpdocs/elementindex.html delete mode 100644 SolrPhpClient/phpdocs/elementindex_Apache.html delete mode 100644 SolrPhpClient/phpdocs/errors.html delete mode 100644 SolrPhpClient/phpdocs/index.html delete mode 100644 SolrPhpClient/phpdocs/li_Apache.html delete mode 100644 SolrPhpClient/phpdocs/media/banner.css delete mode 100644 SolrPhpClient/phpdocs/media/stylesheet.css delete mode 100644 SolrPhpClient/phpdocs/packages.html delete mode 100644 SolrPhpClient/phpdocs/todolist.html delete mode 100644 SolrPhpClient/tests/Apache/Solr/DocumentTest.php delete mode 100644 SolrPhpClient/tests/Apache/Solr/HttpTransport/AbstractTest.php delete mode 100644 SolrPhpClient/tests/Apache/Solr/HttpTransport/CurlNoReuseTest.php delete mode 100644 SolrPhpClient/tests/Apache/Solr/HttpTransport/CurlTest.php delete mode 100644 SolrPhpClient/tests/Apache/Solr/HttpTransport/FileGetContentsTest.php delete mode 100644 SolrPhpClient/tests/Apache/Solr/HttpTransport/ResponseTest.php delete mode 100644 SolrPhpClient/tests/Apache/Solr/HttpTransportExceptionTest.php delete mode 100644 SolrPhpClient/tests/Apache/Solr/ResponseTest.php delete mode 100644 SolrPhpClient/tests/Apache/Solr/Service/BalancerTest.php delete mode 100644 SolrPhpClient/tests/Apache/Solr/ServiceAbstractTest.php delete mode 100644 SolrPhpClient/tests/Apache/Solr/ServiceTest.php delete mode 100644 SolrPhpClient/tests/README delete mode 100644 SolrPhpClient/tests/phpunit.bootstrap.inc delete mode 100644 SolrPhpClient/tests/phpunit.xml delete mode 100644 SolrPhpClient/tests/run.php create mode 100644 includes/document.inc rename service.inc => includes/service.inc (61%) create mode 100644 includes/solr_connection.inc create mode 100644 includes/solr_connection.interface.inc rename solr_field.inc => includes/solr_field.inc (64%) delete mode 100644 includes/solr_httptransport.inc create mode 100644 search_api_solr.admin.inc create mode 100644 solr-conf/1.4/elevate.xml create mode 100644 solr-conf/1.4/mapping-ISOLatin1Accent.txt create mode 100644 solr-conf/1.4/schema_extra_fields.xml create mode 100644 solr-conf/1.4/schema_extra_types.xml create mode 100644 solr-conf/1.4/solrconfig_extra.xml create mode 100644 solr-conf/1.4/stopwords.txt create mode 100644 solr-conf/1.4/synonyms.txt create mode 100644 solr-conf/3.x/elevate.xml create mode 100644 solr-conf/3.x/mapping-ISOLatin1Accent.txt create mode 100644 solr-conf/3.x/schema_extra_fields.xml create mode 100644 solr-conf/3.x/schema_extra_types.xml create mode 100644 solr-conf/3.x/solrconfig_extra.xml create mode 100644 solr-conf/3.x/stopwords.txt create mode 100644 solr-conf/3.x/synonyms.txt create mode 100644 solr-conf/4.x/elevate.xml create mode 100644 solr-conf/4.x/mapping-ISOLatin1Accent.txt create mode 100644 solr-conf/4.x/protwords.txt create mode 100644 solr-conf/4.x/schema.xml create mode 100644 solr-conf/4.x/schema_extra_fields.xml create mode 100644 solr-conf/4.x/schema_extra_types.xml create mode 100644 solr-conf/4.x/solrconfig.xml create mode 100644 solr-conf/4.x/solrconfig_extra.xml create mode 100644 solr-conf/4.x/solrcore.properties create mode 100644 solr-conf/4.x/stopwords.txt create mode 100644 solr-conf/4.x/synonyms.txt delete mode 100644 solr_connection.inc diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 82bea17e..af582151 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,6 +1,70 @@ Search API Solr search 1.x, dev (xx/xx/xxxx): --------------------------------------------- +Search API Solr search 1.2 (09/01/2013): +---------------------------------------- +- #1246730 by febbraro, maciej.zgadzaj, drunken monkey: Added a way to alter + the Solr document when indexing. +- #2053553 by drunken monkey, andrewbelcher: Fixed spatial features with clean + field identifiers. +- #2054373 by drunken monkey: Added the option to use clean field identifiers. +- #1992806 by drunken monkey: Documented problems with Solr 4.3+. +- #2045355 by drunken monkey, arpieb: Fixed result mapping of item IDs. +- #2050157 by izus: Fixed typo in stopwords.txt. + +Search API Solr search 1.1 (07/21/2013): +---------------------------------------- +- #1957730 by drunken monkey: Fixed filter query strings for negated filters. +- #2010818 by kenorb, drunken monkey: Added new Files tab showing all used solr + config files. +- #2042201 by klausi: Fixed timeouts while optimizing Solr server. +- #2034719 by fago: Added raw term to autocompletion response. +- #2027843 by fago, drunken monkey: Made the Solr response available as part of + the search results. +- #1834614 by drunken monkey: Fixed date fields in MLT queries. +- #1970652 by jsteggink: Fixed highlighting for text fields. +- #2016169 by tomdearden, drunken monkey: Fixed parsing of facets on + multi-valued fields. +- #2008034 by bdecarne: Fixed highlighting in multi-index searches. + +Search API Solr search 1.0 (06/09/2013): +---------------------------------------- +- #1896080 by drunken monkey: Included additional required config files in the + module. +- #1919572 by chaby: Fixed indexing of geohashes. +- #2004596 by drunken monkey: Fixed "More Like This" for Solr 4.x. +- #2007214 by drunken monkey: Fixed unsetting of object properties. +- #1884312 by drunken monkey, mvc: Fixed resetting of HTTP password upon + re-saving of the configuration form. +- #1957774 by drunken monkey: Fixed displayed link to local Solr servers. +- #1721262 by Steven Jones, das-peter, drunken monkey: Added field collapsing + support. +- #1549244 by cferthorney, drunken monkey: Added SSL Support for Solr servers. + +Search API Solr search 1.0, RC 5 (05/17/2013): +---------------------------------------------- +- #1190462 by drunken monkey: Documented that enabling HTML filter makes sense. +- #1986284 by drunken monkey: Updated common configs to the latest version. +- #1990422 by populist, drunken monkey: Added support for custom stream contexts + for HTTP requests. +- #1957890 by drunken monkey, jwilson3: Fixed several bugs for facets. +- #1676224 by dasjo, morningtime, drunken monkey: Added support for Solr 4.x. +- #1985522 by chaby: Fixed use of instance method in static escape() method. +- #1979102 by drunken monkey: Fixed wrong limit for limit-less searches. +- #1978632 by chaby, drunken monkey: Fixed wrong check on softCommit. +- #1978600 by chaby: Fixed hook_requirements() for install phase. +- #1976930 by drunken monkey: Fixed duplicate method in SearchApiSolrField. + +Search API Solr search 1.0, RC 4 (04/22/2013): +---------------------------------------------- +- #1744250 by mollux, drunken monkey, das-peter: Added support for + location-based searches. +- #1846254 by drunken monkey: Removed the SolrPhpClient dependency. +- #1934450 by jwilson3, jlapp: Fixed reference to removed method + getFacetField(). +- #1900644 by Deciphered: Fixed facet handling for multi-index searches. +- #1897386 by drunken monkey, NIck_vh: Update the common schema. + Search API Solr search 1.0, RC 3 (01/06/2013): ---------------------------------------------- - #1828260 by drunken monkey: Fixed filtering by index in multi-index searches. diff --git a/INSTALL.txt b/INSTALL.txt index 18cb6c73..d8c1827a 100644 --- a/INSTALL.txt +++ b/INSTALL.txt @@ -1,39 +1,3 @@ -Prerequisite: -- Java 6 or higher - -Steps necessary: -- Download Solr PHP client -- Setting up Solr - -Download Solr PHP client ------------------------- - -This module uses an external PHP library for communicating with Solr servers. Go -to [1] and download version r60 of this library. (The older version r22 is also -still supported, but this might change in the future.) - -[1] http://code.google.com/p/solr-php-client/downloads/list - -Afterwards, unpack this archive to Drupal's libraries folder, so the directory -tree looks like this: - -DRUPAL_ROOT/sites/all/libraries/ - |- SolrPhpClient - |- Apache/ - |- ChangeLog - ... - -The library should then be found by the module. - -Note: If you have the Libraries API [2] module installed, you can also place the -library into any other directory recognized by the Libraries API, e.g. -(depending on the module version): -- DRUPAL_ROOT/libraries -- DRUPAL_ROOT/profiles/PROFILE/libraries -- DRUPAL_ROOT/sites/CONF_DIR/libraries - -[2] http://drupal.org/project/libraries - Setting up Solr --------------- @@ -41,38 +5,71 @@ In order for this module to work, you will first need to set up a Solr server. For this, you can either purchase a server from a web Solr hosts or set up your own Solr server on your web server (if you have the necessary rights to do so). If you want to use a hosted solution, a number of companies are listed on the -module's project page [3]. Otherwise, please follow the instructions below. +module's project page [1]. Otherwise, please follow the instructions below. +A more detailed set of instructions is available at [2]. -[3] http://drupal.org/project/search_api_solr +[1] https://drupal.org/project/search_api_solr +[2] https://drupal.org/node/1999310 -Download the latest version of Solr 3.x from [4] and unpack the archive +As a pre-requisite for running your own Solr server, you'll need Java 6 or +higher. + +Download the latest version of Solr 4.x from [3] and unpack the archive somewhere outside of your web server's document tree. -[4] http://www.apache.org/dyn/closer.cgi/lucene/solr/ +[3] http://www.apache.org/dyn/closer.cgi/lucene/solr/ -This module also supports Solr 1.4, but its use is discouraged due to worse -performance and some features not being supported. Solr 4.x is not supported by -this module yet. +This module also supports Solr 1.4 and 3.x. For better performance and more +features, 4.x should be used, though. 1.4 is discouraged altogether, as several +features of the module don't work at all in 1.4. For small websites, using the example application, located in $SOLR/example/, usually suffices. In any case, you can use it for developing andd testing. The following instructions will assume you are using the example application, otherwise you should be able to substitute the corresponding paths. +NOTE: The Solr 4.3+ example application is currently not completely supported +with the configuration files included in this module, due to a slight change in +directory structure. To fix this, simply copy, move or symlink the contrib/ +directory from the top level of the extracted Solr package one level down to +example/. +(For other directory structures: the contrib/ directory has to be in the +directory two levels up from the one which includes the conf/ directory. For +help, just start the Solr server and check the log files for WARN messages – +they should state in which place Solr expects the directory to be.) + +CAUTION! For production sites, it is vital that you somehow prevent outside +access to the Solr server. Otherwise, attackers could read, corrupt or delete +all your indexed data. Using the example server WON'T prevent this by default. +If it is available, the probably easiest way of preventing this is to disable +outside access to the ports used by Solr through your server's network +configuration or through the use of a firewall. +Other options include adding basic HTTP authentication or renaming the solr/ +directory to a random string of characters and using that as the path. + Before starting the Solr server you will have to make sure it uses the proper configuration files. These are located in the solr-conf/ directory in this module, in a sub-directory according to the Solr version you are using. Copy all the files from that directory into Solr's configuration directory -($SOLR/example/solr/conf/ in case of the example application), after backing up -all files that would be overwritten. +($SOLR/example/solr/collection1/conf/ in case of the 4.x example application), +after backing up all files that would be overwritten. + +NOTE: The mapping-ISOLatin1Accent.txt is only included in the module for +completeness' sake, as it is required to start the Solr server. It will be +usually advisable to just use the file of the example application in this case, +though, as it contains really useful definitions, while the file provided with +this module is empty, apart from some documentation. For licensing reasons, it +is not possible for us to include the definitions in the example config file in +the copy this module provides. + You can then start Solr. For the example application, go to $SOLR/example/ and issue the following command (assuming Java is correctly installed): -java -jar start.jar +java -jar start.jar & -Afterwards, go to [5] in your web browser to ensure Solr is running correctly. +Afterwards, go to [4] in your web browser to ensure Solr is running correctly. -[5] http://localhost:8983/solr/admin/ +[4] http://localhost:8983/solr/#/ You can then enable this module and create a new server, using the "Solr search" service class. Enter the hostname, port and path corresponding to your Solr diff --git a/README.txt b/README.txt index 25fbf82d..192bdad8 100644 --- a/README.txt +++ b/README.txt @@ -5,6 +5,10 @@ This module provides an implementation of the Search API which uses an Apache Solr search server for indexing and searching. Before enabling or using this module, you'll have to follow the instructions given in INSTALL.txt first. +For more detailed documentation, see the handbook [1]. + +[1] https://drupal.org/node/1999280 + Supported optional features --------------------------- @@ -15,13 +19,13 @@ can be changed arbitrarily. Using your own Solr extensions is thereby also possible. The "direct" parse mode for queries will result in the keys being directly used -as the query to Solr. For details about Lucene's query syntax, see [1]. There -are also some Solr additions to this, listed at [2]. Note however that, by +as the query to Solr. For details about Lucene's query syntax, see [2]. There +are also some Solr additions to this, listed at [3]. Note however that, by default, this module uses the dismax query handler, so searches like "field:value" won't work with the "direct" mode. -[1] http://lucene.apache.org/java/2_9_1/queryparsersyntax.html -[2] http://wiki.apache.org/solr/SolrQuerySyntax +[2] http://lucene.apache.org/java/2_9_1/queryparsersyntax.html +[3] http://wiki.apache.org/solr/SolrQuerySyntax Regarding third-party features, the following are supported: @@ -40,6 +44,10 @@ Regarding third-party features, the following are supported: Introduced by module: search_api_views Lets you display items that are similar to a given one. Use, e.g., to create a "More like this" block for node pages. + NOTE: Due to a regression in Solr itself, "More like this" doesn't work with + integer and float fields in Solr 4. As a work-around, you can index the fields + (or copies of them) as string values. See [4] for details. + Also, MLT with date fields isn't currently supported at all for any version. - search_api_multi Introduced by module: search_api_multi Allows you to search multiple indexes at once, as long as they are on the same @@ -48,12 +56,24 @@ Regarding third-party features, the following are supported: - search_api_spellcheck Introduced by module: search_api_spellcheck Gives the option to display automatic spellchecking for searches. +- search_api_data_type_location + Introduced by module: search_api_location + Lets you index, filter and sort on location fields. Note, however, that only + single-valued fields are currently supported for Solr 3.x, and that the option + isn't supported at all in Solr 1.4. +- search_api_grouping + Introduced by module: search_api_grouping [5] + Lets you group search results based on indexed fields. For further information + see the FieldCollapsing documentation in the solr wiki [6]. If you feel some service option is missing, or have other ideas for improving this implementation, please file a feature request in the project's issue queue, -at [3]. +at [7]. -[3] http://drupal.org/project/issues/search_api_solr +[4] https://drupal.org/node/2004596 +[5] https://drupal.org/sandbox/daspeter/1783280 +[6] http://wiki.apache.org/solr/FieldCollapsing +[7] https://drupal.org/project/issues/search_api_solr Specifics --------- @@ -62,7 +82,9 @@ Please consider that, since Solr handles tokenizing, stemming and other preprocessing tasks, activating any preprocessors in a search index' settings is usually not needed or even cumbersome. If you are adding an index to a Solr server you should therefore then disable all processors which handle such -classic preprocessing tasks. +classic preprocessing tasks. Enabling the HTML filter can be useful, though, as +the default config files included in this module don't handle stripping out HTML +tags. Also, due to the way Solr works, using a single field for fulltext searching will result in the smallest index size and best search performance, as well as @@ -71,6 +93,19 @@ different sets of fields in different searches on an index, it is adviced that you collect all fields that should be searchable into a single field using the “Aggregated fields” data alteration. +Clean field identifiers: + If your Solr server was created in a module version prior to 1.2, you will get + the option to switch the server to "Clean field identifiers" (which is default + for all new servers). This will change the Solr field names used for all + fields whose Search API identifiers contain a colon (i.e., all nested fields) + to support some advanced functionality, like sorting by distance, for which + Solr is buggy when using field names with colons. + The only downside of this change is that the data in Solr for these fields + will become invalid, so all indexes on the server which contain such fields + will be scheduled for re-indexing. (If you don't want to search on incomplete + data until the re-indexing is finished, you can additionally manually clear + the indexes, on their Status tabs, to prevent this.) + Hidden variables ---------------- @@ -86,11 +121,11 @@ The schema.xml and solrconfig.xml files contain extensive comments on how to add additional features or modify behaviour, e.g., for adding a language- specific stemmer or a stopword list. If you are interested in further customizing your Solr server to your needs, -see the Solr wiki at [4] for documentation. When editing the schema.xml and +see the Solr wiki at [8] for documentation. When editing the schema.xml and solrconfig.xml files, please only edit the copies in the Solr configuration directory, not directly the ones provided with this module. -[4] http://wiki.apache.org/solr/ +[8] http://wiki.apache.org/solr/ You'll have to restart your Solr server after making such changes, for them to take effect. diff --git a/SolrPhpClient/Apache/Solr/Document.php b/SolrPhpClient/Apache/Solr/Document.php deleted file mode 100644 index 7b9784a7..00000000 --- a/SolrPhpClient/Apache/Solr/Document.php +++ /dev/null @@ -1,367 +0,0 @@ - - */ - -/** - * Holds Key / Value pairs that represent a Solr Document along with any associated boost - * values. 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 $fieldName => $fieldValue) - * { - * ... - * } - * - */ -class Apache_Solr_Document implements IteratorAggregate -{ - /** - * SVN Revision meta data for this class - */ - const SVN_REVISION = '$Revision: 54 $'; - - /** - * SVN ID meta data for this class - */ - const SVN_ID = '$Id: Document.php 54 2011-02-04 16:29:18Z donovan.jimenez $'; - - /** - * Document boost value - * - * @var float - */ - protected $_documentBoost = false; - - /** - * Document field values, indexed by name - * - * @var array - */ - protected $_fields = array(); - - /** - * Document field boost values, indexed by name - * - * @var array array of floats - */ - protected $_fieldBoosts = array(); - - /** - * Clear all boosts and fields from this document - */ - public function clear() - { - $this->_documentBoost = false; - - $this->_fields = array(); - $this->_fieldBoosts = array(); - } - - /** - * Get current document boost - * - * @return mixed will be false for default, or else a float - */ - public function getBoost() - { - return $this->_documentBoost; - } - - /** - * Set document boost factor - * - * @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false - */ - public function setBoost($boost) - { - $boost = (float) $boost; - - if ($boost > 0.0) - { - $this->_documentBoost = $boost; - } - else - { - $this->_documentBoost = false; - } - } - - /** - * Add a value to a multi-valued field - * - * NOTE: the solr XML format allows you to specify boosts - * PER value even though the underlying Lucene implementation - * only allows a boost per field. To remedy this, the final - * field boost value will be the product of all specified boosts - * on field values - this is similar to SolrJ's functionality. - * - * - * $doc = new Apache_Solr_Document(); - * - * $doc->addField('foo', 'bar', 2.0); - * $doc->addField('foo', 'baz', 3.0); - * - * // resultant field boost will be 6! - * echo $doc->getFieldBoost('foo'); - * - * - * @param string $key - * @param mixed $value - * @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false - */ - public function addField($key, $value, $boost = false) - { - if (!isset($this->_fields[$key])) - { - // create holding array if this is the first value - $this->_fields[$key] = array(); - } - else if (!is_array($this->_fields[$key])) - { - // move existing value into array if it is not already an array - $this->_fields[$key] = array($this->_fields[$key]); - } - - if ($this->getFieldBoost($key) === false) - { - // boost not already set, set it now - $this->setFieldBoost($key, $boost); - } - else if ((float) $boost > 0.0) - { - // multiply passed boost with current field boost - similar to SolrJ implementation - $this->_fieldBoosts[$key] *= (float) $boost; - } - - // add value to array - $this->_fields[$key][] = $value; - } - - /** - * Handle the array manipulation for a multi-valued field - * - * @param string $key - * @param string $value - * @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false - * - * @deprecated Use addField(...) instead - */ - public function setMultiValue($key, $value, $boost = false) - { - $this->addField($key, $value, $boost); - } - - /** - * Get field information - * - * @param string $key - * @return mixed associative array of info if field exists, false otherwise - */ - public function getField($key) - { - if (isset($this->_fields[$key])) - { - return array( - 'name' => $key, - 'value' => $this->_fields[$key], - 'boost' => $this->getFieldBoost($key) - ); - } - - return false; - } - - /** - * Set a field value. Multi-valued fields should be set as arrays - * or instead use the addField(...) function which will automatically - * make sure the field is an array. - * - * @param string $key - * @param mixed $value - * @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false - */ - public function setField($key, $value, $boost = false) - { - $this->_fields[$key] = $value; - $this->setFieldBoost($key, $boost); - } - - /** - * Get the currently set field boost for a document field - * - * @param string $key - * @return float currently set field boost, false if one is not set - */ - public function getFieldBoost($key) - { - return isset($this->_fieldBoosts[$key]) ? $this->_fieldBoosts[$key] : false; - } - - /** - * Set the field boost for a document field - * - * @param string $key field name for the boost - * @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false - */ - public function setFieldBoost($key, $boost) - { - $boost = (float) $boost; - - if ($boost > 0.0) - { - $this->_fieldBoosts[$key] = $boost; - } - else - { - $this->_fieldBoosts[$key] = false; - } - } - - /** - * Return current field boosts, indexed by field name - * - * @return array - */ - public function getFieldBoosts() - { - return $this->_fieldBoosts; - } - - /** - * Get the names of all fields in this document - * - * @return array - */ - public function getFieldNames() - { - return array_keys($this->_fields); - } - - /** - * Get the values of all fields in this document - * - * @return array - */ - public function getFieldValues() - { - return array_values($this->_fields); - } - - /** - * IteratorAggregate implementation function. Allows usage: - * - * - * foreach ($document as $key => $value) - * { - * ... - * } - * - */ - public function getIterator() - { - $arrayObject = new ArrayObject($this->_fields); - - return $arrayObject->getIterator(); - } - - /** - * Magic get for field values - * - * @param string $key - * @return mixed - */ - public function __get($key) - { - if (isset($this->_fields[$key])) - { - return $this->_fields[$key]; - } - - return null; - } - - /** - * Magic set for field values. Multi-valued fields should be set as arrays - * or instead use the addField(...) function which will automatically - * make sure the field is an array. - * - * @param string $key - * @param mixed $value - */ - public function __set($key, $value) - { - $this->setField($key, $value); - } - - /** - * Magic isset for fields values. Do not 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 not call directly. Allows usage: - * - * - * unset($document->some_field); - * - * - * @param string $key - */ - public function __unset($key) - { - unset($this->_fields[$key]); - unset($this->_fieldBoosts[$key]); - } -} \ No newline at end of file diff --git a/SolrPhpClient/Apache/Solr/Exception.php b/SolrPhpClient/Apache/Solr/Exception.php deleted file mode 100644 index e6bc4f4b..00000000 --- a/SolrPhpClient/Apache/Solr/Exception.php +++ /dev/null @@ -1,50 +0,0 @@ - - */ - -class Apache_Solr_Exception extends Exception -{ - /** - * SVN Revision meta data for this class - */ - const SVN_REVISION = '$Revision: 54 $'; - - /** - * SVN ID meta data for this class - */ - const SVN_ID = '$Id: Exception.php 54 2011-02-04 16:29:18Z donovan.jimenez $'; -} \ No newline at end of file diff --git a/SolrPhpClient/Apache/Solr/HttpTransport/Abstract.php b/SolrPhpClient/Apache/Solr/HttpTransport/Abstract.php deleted file mode 100644 index cf9f76d3..00000000 --- a/SolrPhpClient/Apache/Solr/HttpTransport/Abstract.php +++ /dev/null @@ -1,89 +0,0 @@ -, Donovan Jimenez - */ - -/** - * Convenience class that implements the transport implementation. Can be extended by - * real implementations to do some of the common book keeping - */ -abstract class Apache_Solr_HttpTransport_Abstract implements Apache_Solr_HttpTransport_Interface -{ - /** - * Our default timeout value for requests that don't specify a timeout - * - * @var float - */ - private $_defaultTimeout = false; - - /** - * Get the current default timeout setting (initially the default_socket_timeout ini setting) - * in seconds - * - * @return float - */ - public function getDefaultTimeout() - { - // lazy load the default timeout from the ini settings - if ($this->_defaultTimeout === false) - { - $this->_defaultTimeout = (int) ini_get('default_socket_timeout'); - - // double check we didn't get 0 for a timeout - if ($this->_defaultTimeout <= 0) - { - $this->_defaultTimeout = 60; - } - } - - return $this->_defaultTimeout; - } - - /** - * Set the current default timeout for all HTTP requests - * - * @param float $timeout - */ - public function setDefaultTimeout($timeout) - { - $timeout = (float) $timeout; - - if ($timeout >= 0) - { - $this->_defaultTimeout = $timeout; - } - } -} \ No newline at end of file diff --git a/SolrPhpClient/Apache/Solr/HttpTransport/Curl.php b/SolrPhpClient/Apache/Solr/HttpTransport/Curl.php deleted file mode 100644 index 7cb7743e..00000000 --- a/SolrPhpClient/Apache/Solr/HttpTransport/Curl.php +++ /dev/null @@ -1,198 +0,0 @@ -, Donovan Jimenez - */ - -// Require Apache_Solr_HttpTransport_Abstract -require_once(dirname(__FILE__) . '/Abstract.php'); - -/** - * A Curl based HTTP transport. Uses a single curl session for all requests. - */ -class Apache_Solr_HttpTransport_Curl extends Apache_Solr_HttpTransport_Abstract -{ - /** - * SVN Revision meta data for this class - */ - const SVN_REVISION = '$Revision:$'; - - /** - * SVN ID meta data for this class - */ - const SVN_ID = '$Id:$'; - - /** - * Curl Session Handle - * - * @var resource - */ - private $_curl; - - /** - * Initializes a curl session - */ - public function __construct() - { - // initialize a CURL session - $this->_curl = curl_init(); - - // set common options that will not be changed during the session - curl_setopt_array($this->_curl, array( - // return the response body from curl_exec - CURLOPT_RETURNTRANSFER => true, - - // get the output as binary data - CURLOPT_BINARYTRANSFER => true, - - // we do not need the headers in the output, we get everything we need from curl_getinfo - CURLOPT_HEADER => false - )); - } - - /** - * Closes a curl session - */ - function __destruct() - { - // close our curl session - curl_close($this->_curl); - } - - public function performGetRequest($url, $timeout = false) - { - // check the timeout value - if ($timeout === false || $timeout <= 0.0) - { - // use the default timeout - $timeout = $this->getDefaultTimeout(); - } - - // set curl GET options - curl_setopt_array($this->_curl, array( - // make sure we're returning the body - CURLOPT_NOBODY => false, - - // make sure we're GET - CURLOPT_HTTPGET => true, - - // set the URL - CURLOPT_URL => $url, - - // set the timeout - CURLOPT_TIMEOUT => $timeout - )); - - // make the request - $responseBody = curl_exec($this->_curl); - - // get info from the transfer - $statusCode = curl_getinfo($this->_curl, CURLINFO_HTTP_CODE); - $contentType = curl_getinfo($this->_curl, CURLINFO_CONTENT_TYPE); - - return new Apache_Solr_HttpTransport_Response($statusCode, $contentType, $responseBody); - } - - public function performHeadRequest($url, $timeout = false) - { - // check the timeout value - if ($timeout === false || $timeout <= 0.0) - { - // use the default timeout - $timeout = $this->getDefaultTimeout(); - } - - // set curl HEAD options - curl_setopt_array($this->_curl, array( - // this both sets the method to HEAD and says not to return a body - CURLOPT_NOBODY => true, - - // set the URL - CURLOPT_URL => $url, - - // set the timeout - CURLOPT_TIMEOUT => $timeout - )); - - // make the request - $responseBody = curl_exec($this->_curl); - - // get info from the transfer - $statusCode = curl_getinfo($this->_curl, CURLINFO_HTTP_CODE); - $contentType = curl_getinfo($this->_curl, CURLINFO_CONTENT_TYPE); - - return new Apache_Solr_HttpTransport_Response($statusCode, $contentType, $responseBody); - } - - public function performPostRequest($url, $postData, $contentType, $timeout = false) - { - // check the timeout value - if ($timeout === false || $timeout <= 0.0) - { - // use the default timeout - $timeout = $this->getDefaultTimeout(); - } - - // set curl POST options - curl_setopt_array($this->_curl, array( - // make sure we're returning the body - CURLOPT_NOBODY => false, - - // make sure we're POST - CURLOPT_POST => true, - - // set the URL - CURLOPT_URL => $url, - - // set the post data - CURLOPT_POSTFIELDS => $postData, - - // set the content type - CURLOPT_HTTPHEADER => array("Content-Type: {$contentType}"), - - // set the timeout - CURLOPT_TIMEOUT => $timeout - )); - - // make the request - $responseBody = curl_exec($this->_curl); - - // get info from the transfer - $statusCode = curl_getinfo($this->_curl, CURLINFO_HTTP_CODE); - $contentType = curl_getinfo($this->_curl, CURLINFO_CONTENT_TYPE); - - return new Apache_Solr_HttpTransport_Response($statusCode, $contentType, $responseBody); - } -} \ No newline at end of file diff --git a/SolrPhpClient/Apache/Solr/HttpTransport/CurlNoReuse.php b/SolrPhpClient/Apache/Solr/HttpTransport/CurlNoReuse.php deleted file mode 100644 index 14549588..00000000 --- a/SolrPhpClient/Apache/Solr/HttpTransport/CurlNoReuse.php +++ /dev/null @@ -1,196 +0,0 @@ -, Donovan Jimenez - */ - -// Require Apache_Solr_HttpTransport_Abstract -require_once(dirname(__FILE__) . '/Abstract.php'); - -/** - * An alternative Curl HTTP transport that opens and closes a curl session for - * every request. This isn't the recommended way to use curl, but some version of - * PHP have memory issues. - */ -class Apache_Solr_HttpTransport_CurlNoReuse extends Apache_Solr_HttpTransport_Abstract -{ - /** - * SVN Revision meta data for this class - */ - const SVN_REVISION = '$Revision:$'; - - /** - * SVN ID meta data for this class - */ - const SVN_ID = '$Id:$'; - - public function performGetRequest($url, $timeout = false) - { - // check the timeout value - if ($timeout === false || $timeout <= 0.0) - { - // use the default timeout - $timeout = $this->getDefaultTimeout(); - } - - $curl = curl_init(); - - // set curl GET options - curl_setopt_array($curl, array( - // return the response body from curl_exec - CURLOPT_RETURNTRANSFER => true, - - // get the output as binary data - CURLOPT_BINARYTRANSFER => true, - - // we do not need the headers in the output, we get everything we need from curl_getinfo - CURLOPT_HEADER => false, - - // set the URL - CURLOPT_URL => $url, - - // set the timeout - CURLOPT_TIMEOUT => $timeout - )); - - // make the request - $responseBody = curl_exec($curl); - - // get info from the transfer - $statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); - $contentType = curl_getinfo($curl, CURLINFO_CONTENT_TYPE); - - // close our curl session - we're done with it - curl_close($curl); - - return new Apache_Solr_HttpTransport_Response($statusCode, $contentType, $responseBody); - } - - public function performHeadRequest($url, $timeout = false) - { - // check the timeout value - if ($timeout === false || $timeout <= 0.0) - { - // use the default timeout - $timeout = $this->getDefaultTimeout(); - } - - $curl = curl_init(); - - // set curl HEAD options - curl_setopt_array($curl, array( - // return the response body from curl_exec - CURLOPT_RETURNTRANSFER => true, - - // get the output as binary data - CURLOPT_BINARYTRANSFER => true, - - // we do not need the headers in the output, we get everything we need from curl_getinfo - CURLOPT_HEADER => false, - - // this both sets the method to HEAD and says not to return a body - CURLOPT_NOBODY => true, - - // set the URL - CURLOPT_URL => $url, - - // set the timeout - CURLOPT_TIMEOUT => $timeout - )); - - // make the request - $responseBody = curl_exec($curl); - - // get info from the transfer - $statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); - $contentType = curl_getinfo($curl, CURLINFO_CONTENT_TYPE); - - // close our curl session - we're done with it - curl_close($curl); - - return new Apache_Solr_HttpTransport_Response($statusCode, $contentType, $responseBody); - } - - public function performPostRequest($url, $postData, $contentType, $timeout = false) - { - // check the timeout value - if ($timeout === false || $timeout <= 0.0) - { - // use the default timeout - $timeout = $this->getDefaultTimeout(); - } - - $curl = curl_init(); - - // set curl POST options - curl_setopt_array($curl, array( - // return the response body from curl_exec - CURLOPT_RETURNTRANSFER => true, - - // get the output as binary data - CURLOPT_BINARYTRANSFER => true, - - // we do not need the headers in the output, we get everything we need from curl_getinfo - CURLOPT_HEADER => false, - - // make sure we're POST - CURLOPT_POST => true, - - // set the URL - CURLOPT_URL => $url, - - // set the post data - CURLOPT_POSTFIELDS => $postData, - - // set the content type - CURLOPT_HTTPHEADER => array("Content-Type: {$contentType}"), - - // set the timeout - CURLOPT_TIMEOUT => $timeout - )); - - // make the request - $responseBody = curl_exec($curl); - - // get info from the transfer - $statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); - $contentType = curl_getinfo($curl, CURLINFO_CONTENT_TYPE); - - // close our curl session - we're done with it - curl_close($curl); - - return new Apache_Solr_HttpTransport_Response($statusCode, $contentType, $responseBody); - } -} \ No newline at end of file diff --git a/SolrPhpClient/Apache/Solr/HttpTransport/FileGetContents.php b/SolrPhpClient/Apache/Solr/HttpTransport/FileGetContents.php deleted file mode 100644 index 5e01775c..00000000 --- a/SolrPhpClient/Apache/Solr/HttpTransport/FileGetContents.php +++ /dev/null @@ -1,216 +0,0 @@ - - */ - -// Require Apache_Solr_HttpTransport_Abstract -require_once(dirname(__FILE__) . '/Abstract.php'); - -/** - * HTTP Transport implemenation that uses the builtin http URL wrappers and file_get_contents - */ -class Apache_Solr_HttpTransport_FileGetContents extends Apache_Solr_HttpTransport_Abstract -{ - /** - * SVN Revision meta data for this class - */ - const SVN_REVISION = '$Revision: $'; - - /** - * SVN ID meta data for this class - */ - const SVN_ID = '$Id: $'; - - /** - * Reusable stream context resources for GET and POST operations - * - * @var resource - */ - private $_getContext, $_headContext, $_postContext; - - /** - * Initializes our reuseable get and post stream contexts - */ - public function __construct() - { - $this->_getContext = stream_context_create(); - $this->_headContext = stream_context_create(); - $this->_postContext = stream_context_create(); - } - - public function performGetRequest($url, $timeout = false) - { - // set the timeout if specified - if ($timeout !== FALSE && $timeout > 0.0) - { - // timeouts with file_get_contents seem to need - // to be halved to work as expected - $timeout = (float) $timeout / 2; - - stream_context_set_option($this->_getContext, 'http', 'timeout', $timeout); - } - else - { - // use the default timeout pulled from default_socket_timeout otherwise - stream_context_set_option($this->_getContext, 'http', 'timeout', $this->getDefaultTimeout()); - } - - // $http_response_headers will be updated by the call to file_get_contents later - // see http://us.php.net/manual/en/wrappers.http.php for documentation - // Unfortunately, it will still create a notice in analyzers if we don't set it here - $http_response_header = null; - $responseBody = @file_get_contents($url, false, $this->_getContext); - - return $this->_getResponseFromParts($responseBody, $http_response_header); - } - - public function performHeadRequest($url, $timeout = false) - { - stream_context_set_option($this->_headContext, array( - 'http' => array( - // set HTTP method - 'method' => 'HEAD', - - // default timeout - 'timeout' => $this->getDefaultTimeout() - ) - ) - ); - - // set the timeout if specified - if ($timeout !== FALSE && $timeout > 0.0) - { - // timeouts with file_get_contents seem to need - // to be halved to work as expected - $timeout = (float) $timeout / 2; - - stream_context_set_option($this->_headContext, 'http', 'timeout', $timeout); - } - - // $http_response_headers will be updated by the call to file_get_contents later - // see http://us.php.net/manual/en/wrappers.http.php for documentation - // Unfortunately, it will still create a notice in analyzers if we don't set it here - $http_response_header = null; - $responseBody = @file_get_contents($url, false, $this->_headContext); - - return $this->_getResponseFromParts($responseBody, $http_response_header); - } - - public function performPostRequest($url, $rawPost, $contentType, $timeout = false) - { - stream_context_set_option($this->_postContext, array( - 'http' => array( - // set HTTP method - 'method' => 'POST', - - // Add our posted content type - 'header' => "Content-Type: $contentType", - - // the posted content - 'content' => $rawPost, - - // default timeout - 'timeout' => $this->getDefaultTimeout() - ) - ) - ); - - // set the timeout if specified - if ($timeout !== FALSE && $timeout > 0.0) - { - // timeouts with file_get_contents seem to need - // to be halved to work as expected - $timeout = (float) $timeout / 2; - - stream_context_set_option($this->_postContext, 'http', 'timeout', $timeout); - } - - // $http_response_header will be updated by the call to file_get_contents later - // see http://us.php.net/manual/en/wrappers.http.php for documentation - // Unfortunately, it will still create a notice in analyzers if we don't set it here - $http_response_header = null; - $responseBody = @file_get_contents($url, false, $this->_postContext); - - // reset content of post context to reclaim memory - stream_context_set_option($this->_postContext, 'http', 'content', ''); - - return $this->_getResponseFromParts($responseBody, $http_response_header); - } - - private function _getResponseFromParts($rawResponse, $httpHeaders) - { - //Assume 0, false as defaults - $status = 0; - $contentType = false; - - //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') - { - // we can do a intval on status line without the "HTTP/1.X " to get the code - $status = intval(substr($httpHeaders[0], 9)); - - // remove this from the headers so we can check for more - 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) - { - // look for the header that starts appropriately - if (strncasecmp($header, 'Content-Type:', 13) == 0) - { - $contentType = substr($header, 13); - break; - } - } - } - - return new Apache_Solr_HttpTransport_Response($status, $contentType, $rawResponse); - } -} \ No newline at end of file diff --git a/SolrPhpClient/Apache/Solr/HttpTransport/Interface.php b/SolrPhpClient/Apache/Solr/HttpTransport/Interface.php deleted file mode 100644 index 090fc27a..00000000 --- a/SolrPhpClient/Apache/Solr/HttpTransport/Interface.php +++ /dev/null @@ -1,94 +0,0 @@ -, Donovan Jimenez - */ - -// require Apache_Solr_HttpTransport_Response -require_once(dirname(__FILE__) . '/Response.php'); - -/** - * Interface that all Transport (HTTP Requester) implementations must implement. These - * Implementations can then be plugged into the Service instance in order to user their - * the desired method for making HTTP requests - */ -interface Apache_Solr_HttpTransport_Interface -{ - /** - * Get the current default timeout for all HTTP requests - * - * @return float - */ - public function getDefaultTimeout(); - - /** - * Set the current default timeout for all HTTP requests - * - * @param float $timeout - */ - public function setDefaultTimeout($timeout); - - /** - * Perform a GET HTTP operation with an optional timeout and return the response - * contents, use getLastResponseHeaders to retrieve HTTP headers - * - * @param string $url - * @param float $timeout - * @return Apache_Solr_HttpTransport_Response HTTP response - */ - public function performGetRequest($url, $timeout = false); - - /** - * Perform a HEAD HTTP operation with an optional timeout and return the response - * headers - NOTE: head requests have no response body - * - * @param string $url - * @param float $timeout - * @return Apache_Solr_HttpTransport_Response HTTP response - */ - public function performHeadRequest($url, $timeout = false); - - /** - * Perform a POST HTTP operation with an optional timeout and return the response - * contents, use getLastResponseHeaders to retrieve HTTP headers - * - * @param string $url - * @param string $rawPost - * @param string $contentType - * @param float $timeout - * @return Apache_Solr_HttpTransport_Response HTTP response - */ - public function performPostRequest($url, $rawPost, $contentType, $timeout = false); -} \ No newline at end of file diff --git a/SolrPhpClient/Apache/Solr/HttpTransport/Response.php b/SolrPhpClient/Apache/Solr/HttpTransport/Response.php deleted file mode 100644 index 3f113aee..00000000 --- a/SolrPhpClient/Apache/Solr/HttpTransport/Response.php +++ /dev/null @@ -1,255 +0,0 @@ - - */ - -/** - * Represents the required pieces of an HTTP response provided by HTTP transport - * implementations and then consumed by the Apache_Solr_Response class which provides - * decoding - */ -class Apache_Solr_HttpTransport_Response -{ - /** - * Status Messages indexed by Status Code - * Obtained from: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html - * - * @var array - */ - static private $_defaultStatusMessages = array( - // Specific to PHP Solr Client - 0 => "Communication Error", - - // Informational 1XX - 100 => "Continue", - 101 => "Switching Protocols", - - // Successful 2XX - 200 => "OK", - 201 => "Created", - 202 => "Accepted", - 203 => "Non-Authoritative Information", - 204 => "No Content", - 205 => "Reset Content", - 206 => "Partial Content", - - // Redirection 3XX - 300 => "Multiple Choices", - 301 => "Moved Permanently", - 302 => "Found", - 303 => "See Other", - 304 => "Not Modified", - 305 => "Use Proxy", - 307 => "Temporary Redirect", - - // Client Error 4XX - 400 => "Bad Request", - 401 => "Unauthorized", - 402 => "Payment Required", - 403 => "Forbidden", - 404 => "Not Found", - 405 => "Method Not Allowed", - 406 => "Not Acceptable", - 407 => "Proxy Authentication Required", - 408 => "Request Timeout", - 409 => "Conflict", - 410 => "Gone", - 411 => "Length Required", - 412 => "Precondition Failed", - 413 => "Request Entity Too Large", - 414 => "Request-URI Too Long", - 415 => "Unsupported Media Type", - 416 => "Request Range Not Satisfiable", - 417 => "Expectation Failed", - - // Server Error 5XX - 500 => "Internal Server Error", - 501 => "Not Implemented", - 502 => "Bad Gateway", - 503 => "Service Unavailable", - 504 => "Gateway Timeout", - 505 => "HTTP Version Not Supported" - ); - - /** - * Get the HTTP status message based on status code - * - * @return string - */ - public static function getDefaultStatusMessage($statusCode) - { - $statusCode = (int) $statusCode; - - if (isset(self::$_defaultStatusMessages[$statusCode])) - { - return self::$_defaultStatusMessages[$statusCode]; - } - - return "Unknown Status"; - } - - /** - * The response's HTTP status code - * - * @var integer - */ - private $_statusCode; - - /** - * The response's HTTP status message - * - * @var string - */ - private $_statusMessage; - - /** - * The response's mime type - * - * @var string - */ - private $_mimeType; - - /** - * The response's character encoding - * - * @var string - */ - private $_encoding; - - /** - * The response's data - * - * @var string - */ - private $_responseBody; - - /** - * Construct a HTTP transport response - * - * @param integer $statusCode The HTTP status code - * @param string $contentType The VALUE of the Content-Type HTTP header - * @param string $responseBody The body of the HTTP response - */ - public function __construct($statusCode, $contentType, $responseBody) - { - // set the status code, make sure its an integer - $this->_statusCode = (int) $statusCode; - - // lookup up status message based on code - $this->_statusMessage = self::getDefaultStatusMessage($this->_statusCode); - - // set the response body, it should always be a string - $this->_responseBody = (string) $responseBody; - - // parse the content type header value for mimetype and encoding - // first set default values that will remain if we can't find - // what we're looking for in the content type - $this->_mimeType = "text/plain"; - $this->_encoding = "UTF-8"; - - if ($contentType) - { - // now break apart the header to see if there's character encoding - $contentTypeParts = explode(';', $contentType, 2); - - if (isset($contentTypeParts[0])) - { - $this->_mimeType = trim($contentTypeParts[0]); - } - - if (isset($contentTypeParts[1])) - { - // we have a second part, split it further - $contentTypeParts = explode('=', $contentTypeParts[1]); - - if (isset($contentTypeParts[1])) - { - $this->_encoding = trim($contentTypeParts[1]); - } - } - } - } - - /** - * Get the status code of the response - * - * @return integer - */ - public function getStatusCode() - { - return $this->_statusCode; - } - - /** - * Get the status message of the response - * - * @return string - */ - public function getStatusMessage() - { - return $this->_statusMessage; - } - - /** - * Get the mimetype of the response body - * - * @return string - */ - public function getMimeType() - { - return $this->_mimeType; - } - - /** - * Get the charset encoding of the response body. - * - * @return string - */ - public function getEncoding() - { - return $this->_encoding; - } - - /** - * Get the raw response body - * - * @return string - */ - public function getBody() - { - return $this->_responseBody; - } -} diff --git a/SolrPhpClient/Apache/Solr/HttpTransportException.php b/SolrPhpClient/Apache/Solr/HttpTransportException.php deleted file mode 100644 index 83c0001b..00000000 --- a/SolrPhpClient/Apache/Solr/HttpTransportException.php +++ /dev/null @@ -1,79 +0,0 @@ - - */ - -class Apache_Solr_HttpTransportException extends Apache_Solr_Exception -{ - /** - * SVN Revision meta data for this class - */ - const SVN_REVISION = '$Revision: 54 $'; - - /** - * SVN ID meta data for this class - */ - const SVN_ID = '$Id: HttpTransportException.php 54 2011-02-04 16:29:18Z donovan.jimenez $'; - - /** - * Response for which exception was generated - * - * @var Apache_Solr_Response - */ - private $_response; - - /** - * HttpTransportException Constructor - * - * @param Apache_Solr_Response $response - */ - public function __construct(Apache_Solr_Response $response) - { - parent::__construct("'{$response->getHttpStatus()}' Status: {$response->getHttpStatusMessage()}", $response->getHttpStatus()); - - $this->_response = $response; - } - - /** - * Get the response for which this exception was generated - * - * @return Apache_Solr_Response - */ - public function getResponse() - { - return $this->_response; - } -} \ No newline at end of file diff --git a/SolrPhpClient/Apache/Solr/InvalidArgumentException.php b/SolrPhpClient/Apache/Solr/InvalidArgumentException.php deleted file mode 100644 index 273f3d06..00000000 --- a/SolrPhpClient/Apache/Solr/InvalidArgumentException.php +++ /dev/null @@ -1,50 +0,0 @@ - - */ - -class Apache_Solr_InvalidArgumentException extends Apache_Solr_Exception -{ - /** - * SVN Revision meta data for this class - */ - const SVN_REVISION = '$Revision: 54 $'; - - /** - * SVN ID meta data for this class - */ - const SVN_ID = '$Id: InvalidArgumentException.php 54 2011-02-04 16:29:18Z donovan.jimenez $'; -} \ No newline at end of file diff --git a/SolrPhpClient/Apache/Solr/NoServiceAvailableException.php b/SolrPhpClient/Apache/Solr/NoServiceAvailableException.php deleted file mode 100644 index eead7320..00000000 --- a/SolrPhpClient/Apache/Solr/NoServiceAvailableException.php +++ /dev/null @@ -1,50 +0,0 @@ - - */ - -class Apache_Solr_NoServiceAvailableException extends Apache_Solr_Exception -{ - /** - * SVN Revision meta data for this class - */ - const SVN_REVISION = '$Revision: 54 $'; - - /** - * SVN ID meta data for this class - */ - const SVN_ID = '$Id: NoServiceAvailableException.php 54 2011-02-04 16:29:18Z donovan.jimenez $'; -} \ No newline at end of file diff --git a/SolrPhpClient/Apache/Solr/ParserException.php b/SolrPhpClient/Apache/Solr/ParserException.php deleted file mode 100644 index 29283dbc..00000000 --- a/SolrPhpClient/Apache/Solr/ParserException.php +++ /dev/null @@ -1,50 +0,0 @@ - - */ - -class Apache_Solr_ParserException extends Apache_Solr_Exception -{ - /** - * SVN Revision meta data for this class - */ - const SVN_REVISION = '$Revision: 54 $'; - - /** - * SVN ID meta data for this class - */ - const SVN_ID = '$Id: ParserException.php 54 2011-02-04 16:29:18Z donovan.jimenez $'; -} \ No newline at end of file diff --git a/SolrPhpClient/Apache/Solr/Response.php b/SolrPhpClient/Apache/Solr/Response.php deleted file mode 100644 index 1a35e568..00000000 --- a/SolrPhpClient/Apache/Solr/Response.php +++ /dev/null @@ -1,247 +0,0 @@ - - */ - -require_once(dirname(__FILE__) . '/ParserException.php'); - -/** - * 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. - */ -class Apache_Solr_Response -{ - /** - * SVN Revision meta data for this class - */ - const SVN_REVISION = '$Revision: 54 $'; - - /** - * SVN ID meta data for this class - */ - const SVN_ID = '$Id: Response.php 54 2011-02-04 16:29:18Z donovan.jimenez $'; - - /** - * Holds the raw response used in construction - * - * @var Apache_Solr_HttpTransport_Response HTTP response - */ - protected $_response; - - /** - * 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 - * - * @return Apache_Solr_HttpTransport_Response HTTP response - * @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(Apache_Solr_HttpTransport_Response $response, $createDocuments = true, $collapseSingleValueArrays = true) - { - $this->_response = $response; - $this->_createDocuments = (bool) $createDocuments; - $this->_collapseSingleValueArrays = (bool) $collapseSingleValueArrays; - } - - /** - * Get the HTTP status code - * - * @return integer - */ - public function getHttpStatus() - { - return $this->_response->getStatusCode(); - } - - /** - * Get the HTTP status message of the response - * - * @return string - */ - public function getHttpStatusMessage() - { - return $this->_response->getStatusMessage(); - } - - /** - * Get content type of this Solr response - * - * @return string - */ - public function getType() - { - return $this->_response->getMimeType(); - } - - /** - * Get character encoding of this response. Should usually be utf-8, but just in case - * - * @return string - */ - public function getEncoding() - { - return $this->_response->getEncoding(); - } - - /** - * Get the raw response as it was given to this object - * - * @return string - */ - public function getRawResponse() - { - return $this->_response->getBody(); - } - - /** - * Magic get to expose the parsed data and to lazily load it - * - * @param string $key - * @return mixed - */ - public function __get($key) - { - if (!$this->_isParsed) - { - $this->_parseData(); - $this->_isParsed = true; - } - - if (isset($this->_parsedData->$key)) - { - return $this->_parsedData->$key; - } - - return null; - } - - /** - * Magic function for isset function on parsed data - * - * @param string $key - * @return boolean - */ - public function __isset($key) - { - if (!$this->_isParsed) - { - $this->_parseData(); - $this->_isParsed = true; - } - - return isset($this->_parsedData->$key); - } - - /** - * Parse the raw response into the parsed_data array for access - * - * @throws Apache_Solr_ParserException If the data could not be parsed - */ - protected function _parseData() - { - //An alternative would be to use Zend_Json::decode(...) - $data = json_decode($this->_response->getBody()); - - // check that we receive a valid JSON response - we should never receive a null - if ($data === null) - { - throw new Apache_Solr_ParserException('Solr response does not appear to be valid JSON, please examine the raw response with getRawResponse() method'); - } - - //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; - } -} \ No newline at end of file diff --git a/SolrPhpClient/Apache/Solr/Service.php b/SolrPhpClient/Apache/Solr/Service.php deleted file mode 100644 index ea9ae376..00000000 --- a/SolrPhpClient/Apache/Solr/Service.php +++ /dev/null @@ -1,1181 +0,0 @@ - - */ - -// See Issue #1 (http://code.google.com/p/solr-php-client/issues/detail?id=1) -// Doesn't follow typical include path conventions, but is more convenient for users -require_once(dirname(__FILE__) . '/Exception.php'); -require_once(dirname(__FILE__) . '/HttpTransportException.php'); -require_once(dirname(__FILE__) . '/InvalidArgumentException.php'); - -require_once(dirname(__FILE__) . '/Document.php'); -require_once(dirname(__FILE__) . '/Response.php'); - -require_once(dirname(__FILE__) . '/HttpTransport/Interface.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 -{ - /** - * SVN Revision meta data for this class - */ - const SVN_REVISION = '$Revision: 59 $'; - - /** - * SVN ID meta data for this class - */ - const SVN_ID = '$Id: Service.php 59 2011-02-08 20:38:59Z donovan.jimenez $'; - - /** - * Response writer we'll request - JSON. See http://code.google.com/p/solr-php-client/issues/detail?id=6#c1 for reasoning - */ - const SOLR_WRITER = 'json'; - - /** - * NamedList Treatment constants - */ - const NAMED_LIST_FLAT = 'flat'; - const NAMED_LIST_MAP = 'map'; - - /** - * Search HTTP Methods - */ - const METHOD_GET = 'GET'; - const METHOD_POST = 'POST'; - - /** - * Servlet mappings - */ - const PING_SERVLET = 'admin/ping'; - const UPDATE_SERVLET = 'update'; - const SEARCH_SERVLET = 'select'; - const THREADS_SERVLET = 'admin/threads'; - const EXTRACT_SERVLET = 'update/extract'; - - /** - * 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 = '&', $_queryBracketsEscaped = true; - - /** - * Constructed servlet full path URLs - * - * @var string - */ - protected $_pingUrl, $_updateUrl, $_searchUrl, $_threadsUrl; - - /** - * Keep track of whether our URLs have been constructed - * - * @var boolean - */ - protected $_urlsInited = false; - - /** - * HTTP Transport implementation (pluggable) - * - * @var Apache_Solr_HttpTransport_Interface - */ - protected $_httpTransport = false; - - /** - * 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 - * @param Apache_Solr_HttpTransport_Interface $httpTransport - */ - public function __construct($host = 'localhost', $port = 8180, $path = '/solr/', $httpTransport = false) - { - $this->setHost($host); - $this->setPort($port); - $this->setPath($path); - - $this->_initUrls(); - - if ($httpTransport) - { - $this->setHttpTransport($httpTransport); - } - - // check that our php version is >= 5.1.3 so we can correct for http_build_query behavior later - $this->_queryBracketsEscaped = version_compare(phpversion(), '5.1.3', '>='); - } - - /** - * 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->_extractUrl = $this->_constructUrl(self::EXTRACT_SERVLET); - $this->_pingUrl = $this->_constructUrl(self::PING_SERVLET); - $this->_searchUrl = $this->_constructUrl(self::SEARCH_SERVLET); - $this->_threadsUrl = $this->_constructUrl(self::THREADS_SERVLET, array('wt' => self::SOLR_WRITER )); - $this->_updateUrl = $this->_constructUrl(self::UPDATE_SERVLET, array('wt' => self::SOLR_WRITER )); - - $this->_urlsInited = true; - } - - protected function _generateQueryString($params) - { - // use http_build_query to encode our arguments because its faster - // than urlencoding all the parts ourselves in a loop - // - // 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 - // - // NOTE: before php 5.1.3 brackets were not url encoded by http_build query - we've checked - // the php version in the constructor and put the results in the instance variable. Also, before - // 5.1.2 the arg_separator parameter was not available, so don't use it - if ($this->_queryBracketsEscaped) - { - $queryString = http_build_query($params, null, $this->_queryStringDelimiter); - return preg_replace('/%5B(?:[0-9]|[1-9][0-9]+)%5D=/', '=', $queryString); - } - else - { - $queryString = http_build_query($params); - return preg_replace('/\\[(?:[0-9]|[1-9][0-9]+)\\]=/', '=', $queryString); - } - } - - /** - * 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 - * - * @throws Apache_Solr_HttpTransportException If a non 200 response status is returned - */ - protected function _sendRawGet($url, $timeout = FALSE) - { - $httpTransport = $this->getHttpTransport(); - - $httpResponse = $httpTransport->performGetRequest($url, $timeout); - $solrResponse = new Apache_Solr_Response($httpResponse, $this->_createDocuments, $this->_collapseSingleValueArrays); - - if ($solrResponse->getHttpStatus() != 200) - { - throw new Apache_Solr_HttpTransportException($solrResponse); - } - - return $solrResponse; - } - - /** - * 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 Apache_Solr_HttpTransportException If a non 200 response status is returned - */ - protected function _sendRawPost($url, $rawPost, $timeout = FALSE, $contentType = 'text/xml; charset=UTF-8') - { - $httpTransport = $this->getHttpTransport(); - - $httpResponse = $httpTransport->performPostRequest($url, $rawPost, $contentType, $timeout); - $solrResponse = new Apache_Solr_Response($httpResponse, $this->_createDocuments, $this->_collapseSingleValueArrays); - - if ($solrResponse->getHttpStatus() != 200) - { - throw new Apache_Solr_HttpTransportException($solrResponse); - } - - return $solrResponse; - } - - /** - * 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 - * - * @throws Apache_Solr_InvalidArgumentException If the host parameter is empty - */ - public function setHost($host) - { - //Use the provided host or use the default - if (empty($host)) - { - throw new Apache_Solr_InvalidArgumentException('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 - * - * @throws Apache_Solr_InvalidArgumentException If the port parameter is empty - */ - public function setPort($port) - { - //Use the provided port or use the default - $port = (int) $port; - - if ($port <= 0) - { - throw new Apache_Solr_InvalidArgumentException('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(); - } - } - - /** - * Get the current configured HTTP Transport - * - * @return HttpTransportInterface - */ - public function getHttpTransport() - { - // lazy load a default if one has not be set - if ($this->_httpTransport === false) - { - require_once(dirname(__FILE__) . '/HttpTransport/FileGetContents.php'); - - $this->_httpTransport = new Apache_Solr_HttpTransport_FileGetContents(); - } - - return $this->_httpTransport; - } - - /** - * Set the HTTP Transport implemenation that will be used for all HTTP requests - * - * @param Apache_Solr_HttpTransport_Interface - */ - public function setHttpTransport(Apache_Solr_HttpTransport_Interface $httpTransport) - { - $this->_httpTransport = $httpTransport; - } - - /** - * 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 boolean $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; - } - - /** - * Get the current default timeout setting (initially the default_socket_timeout ini setting) - * in seconds - * - * @return float - * - * @deprecated Use the getDefaultTimeout method on the HTTP transport implementation - */ - public function getDefaultTimeout() - { - return $this->getHttpTransport()->getDefaultTimeout(); - } - - /** - * Set the default timeout for all calls that aren't passed a specific timeout - * - * @param float $timeout Timeout value in seconds - * - * @deprecated Use the setDefaultTimeout method on the HTTP transport implementation - */ - public function setDefaultTimeout($timeout) - { - $this->getHttpTransport()->setDefaultTimeout($timeout); - } - - /** - * Set how NamedLists should be formatted in the response data. This mainly effects - * the facet counts format. - * - * @param string $namedListTreatment - * @throws Apache_Solr_InvalidArgumentException If invalid option is set - */ - public function setNamedListTreatment($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 Apache_Solr_InvalidArgumentException('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 or HTTP error status occurs - */ - public function ping($timeout = 2) - { - $start = microtime(true); - - $httpTransport = $this->getHttpTransport(); - - $httpResponse = $httpTransport->performHeadRequest($this->_pingUrl, $timeout); - $solrResponse = new Apache_Solr_Response($httpResponse, $this->_createDocuments, $this->_collapseSingleValueArrays); - - if ($solrResponse->getHttpStatus() == 200) - { - return microtime(true) - $start; - } - else - { - 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 Apache_Solr_HttpTransportException 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 Apache_Solr_HttpTransportException 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 - * @param integer $commitWithin The number of milliseconds that a document must be committed within, see @{link http://wiki.apache.org/solr/UpdateXmlMessages#The_Update_Schema} for details. If left empty this property will not be set in the request. - * @return Apache_Solr_Response - * - * @throws Apache_Solr_HttpTransportException If an error occurs during the service call - */ - public function addDocument(Apache_Solr_Document $document, $allowDups = false, $overwritePending = true, $overwriteCommitted = true, $commitWithin = 0) - { - $dupValue = $allowDups ? 'true' : 'false'; - $pendingValue = $overwritePending ? 'true' : 'false'; - $committedValue = $overwriteCommitted ? 'true' : 'false'; - - $commitWithin = (int) $commitWithin; - $commitWithinString = $commitWithin > 0 ? " commitWithin=\"{$commitWithin}\"" : ''; - - $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 - * @param integer $commitWithin The number of milliseconds that a document must be committed within, see @{link http://wiki.apache.org/solr/UpdateXmlMessages#The_Update_Schema} for details. If left empty this property will not be set in the request. - * @return Apache_Solr_Response - * - * @throws Apache_Solr_HttpTransportException If an error occurs during the service call - */ - public function addDocuments($documents, $allowDups = false, $overwritePending = true, $overwriteCommitted = true, $commitWithin = 0) - { - $dupValue = $allowDups ? 'true' : 'false'; - $pendingValue = $overwritePending ? 'true' : 'false'; - $committedValue = $overwriteCommitted ? 'true' : 'false'; - - $commitWithin = (int) $commitWithin; - $commitWithinString = $commitWithin > 0 ? " commitWithin=\"{$commitWithin}\"" : ''; - - $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 = 'getBoost() !== false) - { - $xml .= ' boost="' . $document->getBoost() . '"'; - } - - $xml .= '>'; - - foreach ($document as $key => $value) - { - $key = htmlspecialchars($key, ENT_QUOTES, 'UTF-8'); - $fieldBoost = $document->getFieldBoost($key); - - if (is_array($value)) - { - foreach ($value as $multivalue) - { - $xml .= ''; - } - } - else - { - $xml .= ''; - } - } - - $xml .= ''; - - // replace any control characters to avoid Solr XML parser exception - return $this->_stripCtrlChars($xml); - } - - /** - * Replace control (non-printable) characters from string that are invalid to Solr's XML parser with a space. - * - * @param string $string - * @return string - */ - protected function _stripCtrlChars($string) - { - // See: http://w3.org/International/questions/qa-forms-utf-8.html - // Printable utf-8 does not include any of these chars below x7F - return preg_replace('@[\x00-\x08\x0B\x0C\x0E-\x1F]@', ' ', $string); - } - - /** - * Send a commit command. Will be synchronous unless both wait parameters are set to false. - * - * @param boolean $expungeDeletes Defaults to false, merge segments with deletes away - * @param boolean $waitFlush Defaults to true, block until index changes are flushed to disk - * @param boolean $waitSearcher Defaults to true, block until a new searcher is opened and registered as the main query searcher, making the changes visible - * @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 Apache_Solr_HttpTransportException If an error occurs during the service call - */ - public function commit($expungeDeletes = false, $waitFlush = true, $waitSearcher = true, $timeout = 3600) - { - $expungeValue = $expungeDeletes ? '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 - * @param float $timeout Maximum expected duration of the delete operation on the server (otherwise, will throw a communication exception) - * @return Apache_Solr_Response - * - * @throws Apache_Solr_HttpTransportException If an error occurs during the service call - */ - public function delete($rawPost, $timeout = 3600) - { - return $this->_sendRawPost($this->_updateUrl, $rawPost, $timeout); - } - - /** - * Create a delete document based on document ID - * - * @param string $id Expected to be utf-8 encoded - * @param boolean $fromPending - * @param boolean $fromCommitted - * @param float $timeout Maximum expected duration of the delete operation on the server (otherwise, will throw a communication exception) - * @return Apache_Solr_Response - * - * @throws Apache_Solr_HttpTransportException If an error occurs during the service call - */ - public function deleteById($id, $fromPending = true, $fromCommitted = true, $timeout = 3600) - { - $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, $timeout); - } - - /** - * Create and post a delete document based on multiple document IDs. - * - * @param array $ids Expected to be utf-8 encoded strings - * @param boolean $fromPending - * @param boolean $fromCommitted - * @param float $timeout Maximum expected duration of the delete operation on the server (otherwise, will throw a communication exception) - * @return Apache_Solr_Response - * - * @throws Apache_Solr_HttpTransportException If an error occurs during the service call - */ - public function deleteByMultipleIds($ids, $fromPending = true, $fromCommitted = true, $timeout = 3600) - { - $pendingValue = $fromPending ? 'true' : 'false'; - $committedValue = $fromCommitted ? 'true' : 'false'; - - $rawPost = ''; - - foreach ($ids as $id) - { - //escape special xml characters - $id = htmlspecialchars($id, ENT_NOQUOTES, 'UTF-8'); - - $rawPost .= '' . $id . ''; - } - - $rawPost .= ''; - - return $this->delete($rawPost, $timeout); - } - - /** - * 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 - * @param float $timeout Maximum expected duration of the delete operation on the server (otherwise, will throw a communication exception) - * @return Apache_Solr_Response - * - * @throws Apache_Solr_HttpTransportException If an error occurs during the service call - */ - public function deleteByQuery($rawQuery, $fromPending = true, $fromCommitted = true, $timeout = 3600) - { - $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, $timeout); - } - - /** - * Use Solr Cell to extract document contents. See {@link http://wiki.apache.org/solr/ExtractingRequestHandler} for information on how - * to use Solr Cell and what parameters are available. - * - * NOTE: when passing an Apache_Solr_Document instance, field names and boosts will automatically be prepended by "literal." and "boost." - * as appropriate. Any keys from the $params array will NOT be treated this way. Any mappings from the document will overwrite key / value - * pairs in the params array if they have the same name (e.g. you pass a "literal.id" key and value in your $params array but you also - * pass in a document isntance with an "id" field" - the document's value(s) will take precedence). - * - * @param string $file Path to file to extract data from - * @param array $params optional array of key value pairs that will be sent with the post (see Solr Cell documentation) - * @param Apache_Solr_Document $document optional document that will be used to generate post parameters (literal.* and boost.* params) - * @param string $mimetype optional mimetype specification (for the file being extracted) - * - * @return Apache_Solr_Response - * - * @throws Apache_Solr_InvalidArgumentException if $file, $params, or $document are invalid. - */ - public function extract($file, $params = array(), $document = null, $mimetype = 'application/octet-stream') - { - // check if $params is an array (allow null for default empty array) - if (!is_null($params)) - { - if (!is_array($params)) - { - throw new Apache_Solr_InvalidArgumentException("\$params must be a valid array or null"); - } - } - else - { - $params = array(); - } - - // if $file is an http request, defer to extractFromUrl instead - if (substr($file, 0, 7) == 'http://' || substr($file, 0, 8) == 'https://') - { - return $this->extractFromUrl($file, $params, $document, $mimetype); - } - - // read the contents of the file - $contents = @file_get_contents($file); - - if ($contents !== false) - { - // add the resource.name parameter if not specified - if (!isset($params['resource.name'])) - { - $params['resource.name'] = basename($file); - } - - // delegate the rest to extractFromString - return $this->extractFromString($contents, $params, $document, $mimetype); - } - else - { - throw new Apache_Solr_InvalidArgumentException("File '{$file}' is empty or could not be read"); - } - } - - /** - * Use Solr Cell to extract document contents. See {@link http://wiki.apache.org/solr/ExtractingRequestHandler} for information on how - * to use Solr Cell and what parameters are available. - * - * NOTE: when passing an Apache_Solr_Document instance, field names and boosts will automatically be prepended by "literal." and "boost." - * as appropriate. Any keys from the $params array will NOT be treated this way. Any mappings from the document will overwrite key / value - * pairs in the params array if they have the same name (e.g. you pass a "literal.id" key and value in your $params array but you also - * pass in a document isntance with an "id" field" - the document's value(s) will take precedence). - * - * @param string $data Data that will be passed to Solr Cell - * @param array $params optional array of key value pairs that will be sent with the post (see Solr Cell documentation) - * @param Apache_Solr_Document $document optional document that will be used to generate post parameters (literal.* and boost.* params) - * @param string $mimetype optional mimetype specification (for the file being extracted) - * - * @return Apache_Solr_Response - * - * @throws Apache_Solr_InvalidArgumentException if $file, $params, or $document are invalid. - * - * @todo Should be using multipart/form-data to post parameter values, but I could not get my implementation to work. Needs revisisted. - */ - public function extractFromString($data, $params = array(), $document = null, $mimetype = 'application/octet-stream') - { - // check if $params is an array (allow null for default empty array) - if (!is_null($params)) - { - if (!is_array($params)) - { - throw new Apache_Solr_InvalidArgumentException("\$params must be a valid array or null"); - } - } - else - { - $params = array(); - } - - // make sure we receive our response in JSON and have proper name list treatment - $params['wt'] = self::SOLR_WRITER; - $params['json.nl'] = $this->_namedListTreatment; - - // check if $document is an Apache_Solr_Document instance - if (!is_null($document) && $document instanceof Apache_Solr_Document) - { - // iterate document, adding literal.* and boost.* fields to $params as appropriate - foreach ($document as $field => $fieldValue) - { - // check if we need to add a boost.* parameters - $fieldBoost = $document->getFieldBoost($field); - - if ($fieldBoost !== false) - { - $params["boost.{$field}"] = $fieldBoost; - } - - // add the literal.* parameter - $params["literal.{$field}"] = $fieldValue; - } - } - - // params will be sent to SOLR in the QUERY STRING - $queryString = $this->_generateQueryString($params); - - // the file contents will be sent to SOLR as the POST BODY - we use application/octect-stream as default mimetype - return $this->_sendRawPost($this->_extractUrl . $this->_queryDelimiter . $queryString, $data, false, $mimetype); - } - - /** - * Use Solr Cell to extract document contents. See {@link http://wiki.apache.org/solr/ExtractingRequestHandler} for information on how - * to use Solr Cell and what parameters are available. - * - * NOTE: when passing an Apache_Solr_Document instance, field names and boosts will automatically be prepended by "literal." and "boost." - * as appropriate. Any keys from the $params array will NOT be treated this way. Any mappings from the document will overwrite key / value - * pairs in the params array if they have the same name (e.g. you pass a "literal.id" key and value in your $params array but you also - * pass in a document isntance with an "id" field" - the document's value(s) will take precedence). - * - * @param string $url URL - * @param array $params optional array of key value pairs that will be sent with the post (see Solr Cell documentation) - * @param Apache_Solr_Document $document optional document that will be used to generate post parameters (literal.* and boost.* params) - * @param string $mimetype optional mimetype specification (for the file being extracted) - * - * @return Apache_Solr_Response - * - * @throws Apache_Solr_InvalidArgumentException if $url, $params, or $document are invalid. - */ - public function extractFromUrl($url, $params = array(), $document = null, $mimetype = 'application/octet-stream') - { - // check if $params is an array (allow null for default empty array) - if (!is_null($params)) - { - if (!is_array($params)) - { - throw new Apache_Solr_InvalidArgumentException("\$params must be a valid array or null"); - } - } - else - { - $params = array(); - } - - $httpTransport = $this->getHttpTransport(); - - // read the contents of the URL using our configured Http Transport and default timeout - $httpResponse = $httpTransport->performGetRequest($url); - - // check that its a 200 response - if ($httpResponse->getStatusCode() == 200) - { - // add the resource.name parameter if not specified - if (!isset($params['resource.name'])) - { - $params['resource.name'] = $url; - } - - // delegate the rest to extractFromString - return $this->extractFromString($httpResponse->getBody(), $params, $document, $mimetype); - } - else - { - throw new Apache_Solr_InvalidArgumentException("URL '{$url}' returned non 200 response code"); - } - } - - /** - * 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 Apache_Solr_HttpTransportException 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) - * @param string $method The HTTP method (Apache_Solr_Service::METHOD_GET or Apache_Solr_Service::METHOD::POST) - * @return Apache_Solr_Response - * - * @throws Apache_Solr_HttpTransportException If an error occurs during the service call - * @throws Apache_Solr_InvalidArgumentException If an invalid HTTP method is used - */ - public function search($query, $offset = 0, $limit = 10, $params = array(), $method = self::METHOD_GET) - { - // ensure params is an array - if (!is_null($params)) - { - if (!is_array($params)) - { - // params was specified but was not an array - invalid - throw new Apache_Solr_InvalidArgumentException("\$params must be a valid array or null"); - } - } - else - { - $params = array(); - } - - // construct our full parameters - - // common parameters in this interface - $params['wt'] = self::SOLR_WRITER; - $params['json.nl'] = $this->_namedListTreatment; - - $params['q'] = $query; - $params['start'] = $offset; - $params['rows'] = $limit; - - $queryString = $this->_generateQueryString($params); - - if ($method == self::METHOD_GET) - { - return $this->_sendRawGet($this->_searchUrl . $this->_queryDelimiter . $queryString); - } - else if ($method == self::METHOD_POST) - { - return $this->_sendRawPost($this->_searchUrl, $queryString, FALSE, 'application/x-www-form-urlencoded; charset=UTF-8'); - } - else - { - throw new Apache_Solr_InvalidArgumentException("Unsupported method '$method', please use the Apache_Solr_Service::METHOD_* constants"); - } - } -} \ No newline at end of file diff --git a/SolrPhpClient/Apache/Solr/Service/Balancer.php b/SolrPhpClient/Apache/Solr/Service/Balancer.php deleted file mode 100644 index cad57e52..00000000 --- a/SolrPhpClient/Apache/Solr/Service/Balancer.php +++ /dev/null @@ -1,914 +0,0 @@ -, Dan Wolfe - */ - -// See Issue #1 (http://code.google.com/p/solr-php-client/issues/detail?id=1) -// Doesn't follow typical include path conventions, but is more convenient for users -require_once(dirname(dirname(__FILE__)) . '/Service.php'); - -require_once(dirname(dirname(__FILE__)) . '/NoServiceAvailableException.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 -{ - /** - * SVN Revision meta data for this class - */ - const SVN_REVISION = '$Revision: 54 $'; - - /** - * SVN ID meta data for this class - */ - const SVN_ID = '$Id: Balancer.php 54 2011-02-04 16:29:18Z donovan.jimenez $'; - - 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 Apache_Solr_InvalidArgumentException 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 Apache_Solr_InvalidArgumentException('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 Apache_Solr_InvalidArgumentException 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 Apache_Solr_InvalidArgumentException('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 Apache_Solr_InvalidArgumentException 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 Apache_Solr_InvalidArgumentException('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 Apache_Solr_InvalidArgumentException 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 Apache_Solr_InvalidArgumentException('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 Apache_Solr_NoServiceAvailableException 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 Apache_Solr_NoServiceAvailableException('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 Apache_Solr_NoServiceAvailableException 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 Apache_Solr_NoServiceAvailableException('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 Apache_Solr_NoServiceAvailableException 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 Apache_Solr_NoServiceAvailableException('No write services were available. All timeouts exceeded.'); - } - - } while($this->_writeableServices[$this->_currentWriteService]->ping($backoff) === false); - } - else - { - throw new Apache_Solr_NoServiceAvailableException('No write services were available'); - } - } - - return $this->_writeableServices[$this->_currentWriteService]; - } - - /** - * 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 boolean $createDocuments - */ - public function setCreateDocuments($createDocuments) - { - $this->_createDocuments = (bool) $createDocuments; - - // set on current read service - if ($this->_currentReadService) - { - $service = $this->_selectReadService(); - $service->setCreateDocuments($createDocuments); - } - } - - /** - * Get the current state of teh create documents flag. - * - * @return boolean - */ - 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 Apache_Solr_HttpTransportException If an error occurs during the service call - */ - public function add($rawPost) - { - $service = $this->_selectWriteService(); - - do - { - try - { - return $service->add($rawPost); - } - catch (Apache_Solr_HttpTransportException $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 Apache_Solr_HttpTransportException 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 (Apache_Solr_HttpTransportException $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 Apache_Solr_HttpTransportException 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 (Apache_Solr_HttpTransportException $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 Apache_Solr_HttpTransportException 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 (Apache_Solr_HttpTransportException $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 - * @param float $timeout Maximum expected duration of the delete operation on the server (otherwise, will throw a communication exception) - * @return Apache_Solr_Response - * - * @throws Apache_Solr_HttpTransportException If an error occurs during the service call - */ - public function delete($rawPost, $timeout = 3600) - { - $service = $this->_selectWriteService(); - - do - { - try - { - return $service->delete($rawPost, $timeout); - } - catch (Apache_Solr_HttpTransportException $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 - * @param float $timeout Maximum expected duration of the delete operation on the server (otherwise, will throw a communication exception) - * @return Apache_Solr_Response - * - * @throws Apache_Solr_HttpTransportException If an error occurs during the service call - */ - public function deleteById($id, $fromPending = true, $fromCommitted = true, $timeout = 3600) - { - $service = $this->_selectWriteService(); - - do - { - try - { - return $service->deleteById($id, $fromPending, $fromCommitted, $timeout); - } - catch (Apache_Solr_HttpTransportException $e) - { - if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR - { - throw $e; - } - } - - $service = $this->_selectWriteService(true); - } while ($service); - - return false; - } - - /** - * Create and post a delete document based on multiple document IDs. - * - * @param array $ids Expected to be utf-8 encoded strings - * @param boolean $fromPending - * @param boolean $fromCommitted - * @param float $timeout Maximum expected duration of the delete operation on the server (otherwise, will throw a communication exception) - * @return Apache_Solr_Response - * - * @throws Apache_Solr_HttpTransportException If an error occurs during the service call - */ - public function deleteByMultipleIds($ids, $fromPending = true, $fromCommitted = true, $timeout = 3600) - { - $service = $this->_selectWriteService(); - - do - { - try - { - return $service->deleteByMultipleId($ids, $fromPending, $fromCommitted, $timeout); - } - catch (Apache_Solr_HttpTransportException $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 - * @param float $timeout Maximum expected duration of the delete operation on the server (otherwise, will throw a communication exception) - * @return Apache_Solr_Response - * - * @throws Apache_Solr_HttpTransportException If an error occurs during the service call - */ - public function deleteByQuery($rawQuery, $fromPending = true, $fromCommitted = true, $timeout = 3600) - { - $service = $this->_selectWriteService(); - - do - { - try - { - return $service->deleteByQuery($rawQuery, $fromPending, $fromCommitted, $timeout); - } - catch (Apache_Solr_HttpTransportException $e) - { - if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR - { - throw $e; - } - } - - $service = $this->_selectWriteService(true); - } while ($service); - - return false; - } - - /** - * Use Solr Cell to extract document contents. See {@link http://wiki.apache.org/solr/ExtractingRequestHandler} for information on how - * to use Solr Cell and what parameters are available. - * - * NOTE: when passing an Apache_Solr_Document instance, field names and boosts will automatically be prepended by "literal." and "boost." - * as appropriate. Any keys from the $params array will NOT be treated this way. Any mappings from the document will overwrite key / value - * pairs in the params array if they have the same name (e.g. you pass a "literal.id" key and value in your $params array but you also - * pass in a document isntance with an "id" field" - the document's value(s) will take precedence). - * - * @param string $file Path to file to extract data from - * @param array $params optional array of key value pairs that will be sent with the post (see Solr Cell documentation) - * @param Apache_Solr_Document $document optional document that will be used to generate post parameters (literal.* and boost.* params) - * @param string $mimetype optional mimetype specification (for the file being extracted) - * - * @return Apache_Solr_Response - * - * @throws Apache_Solr_InvalidArgumentException if $file, $params, or $document are invalid. - */ - public function extract($file, $params = array(), $document = null, $mimetype = 'application/octet-stream') - { - $service = $this->_selectWriteService(); - - do - { - try - { - return $service->extract($file, $params, $document, $mimetype); - } - catch (Apache_Solr_HttpTransportException $e) - { - if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR - { - throw $e; - } - } - - $service = $this->_selectWriteService(true); - } while ($service); - - return false; - } - - /** - * Use Solr Cell to extract document contents. See {@link http://wiki.apache.org/solr/ExtractingRequestHandler} for information on how - * to use Solr Cell and what parameters are available. - * - * NOTE: when passing an Apache_Solr_Document instance, field names and boosts will automatically be prepended by "literal." and "boost." - * as appropriate. Any keys from the $params array will NOT be treated this way. Any mappings from the document will overwrite key / value - * pairs in the params array if they have the same name (e.g. you pass a "literal.id" key and value in your $params array but you also - * pass in a document isntance with an "id" field" - the document's value(s) will take precedence). - * - * @param string $data Data that will be passed to Solr Cell - * @param array $params optional array of key value pairs that will be sent with the post (see Solr Cell documentation) - * @param Apache_Solr_Document $document optional document that will be used to generate post parameters (literal.* and boost.* params) - * @param string $mimetype optional mimetype specification (for the file being extracted) - * - * @return Apache_Solr_Response - * - * @throws Apache_Solr_InvalidArgumentException if $file, $params, or $document are invalid. - * - * @todo Should be using multipart/form-data to post parameter values, but I could not get my implementation to work. Needs revisisted. - */ - public function extractFromString($data, $params = array(), $document = null, $mimetype = 'application/octet-stream') - { - $service = $this->_selectWriteService(); - - do - { - try - { - return $service->extractFromString($data, $params, $document, $mimetype); - } - catch (Apache_Solr_HttpTransportException $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 - * @param float $timeout Maximum expected duration of the optimize operation on the server (otherwise, will throw a communication exception) - * @return Apache_Solr_Response - * - * @throws Apache_Solr_HttpTransportException If an error occurs during the service call - */ - public function optimize($waitFlush = true, $waitSearcher = true, $timeout = 3600) - { - $service = $this->_selectWriteService(); - - do - { - try - { - return $service->optimize($waitFlush, $waitSearcher, $timeout); - } - catch (Apache_Solr_HttpTransportException $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 - * @param string $method The HTTP method (Apache_Solr_Service::METHOD_GET or Apache_Solr_Service::METHOD::POST) - * @return Apache_Solr_Response - * - * @throws Apache_Solr_HttpTransportException If an error occurs during the service call - */ - public function search($query, $offset = 0, $limit = 10, $params = array(), $method = Apache_Solr_Service::METHOD_GET) - { - $service = $this->_selectReadService(); - - do - { - try - { - return $service->search($query, $offset, $limit, $params, $method); - } - catch (Apache_Solr_HttpTransportException $e) - { - if ($e->getCode() != 0) //IF NOT COMMUNICATION ERROR - { - throw $e; - } - } - - $service = $this->_selectReadService(true); - } while ($service); - - return false; - } -} diff --git a/SolrPhpClient/COPYING b/SolrPhpClient/COPYING deleted file mode 100644 index 01522fb1..00000000 --- a/SolrPhpClient/COPYING +++ /dev/null @@ -1,26 +0,0 @@ -Copyright (c) 2007-2011, Servigistics, Inc. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * Neither the name of Servigistics, Inc. nor the names of - its contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. diff --git a/SolrPhpClient/ChangeLog b/SolrPhpClient/ChangeLog deleted file mode 100644 index 030e40d5..00000000 --- a/SolrPhpClient/ChangeLog +++ /dev/null @@ -1,342 +0,0 @@ -2011-02-08 20:38 donovan.jimenez - - * Apache/Solr/Service.php, tests/Apache/Solr/ServiceTest.php: See - issue #59 - Adding service extractFromUrl method. This will use - the configured HTTP transport to request the resource. extract - has been modified to detect a file path that starts with http / - https and to defer to extractFromUrl instead. Also, moved - checking for params parameter to the top of method bodies so we - can fail earlier rather than after we've gotten a file / url's - content. - -2011-02-08 19:28 donovan.jimenez - - * Apache/Solr/Service.php, tests/Apache/Solr/ServiceTest.php: See - issue #43 - Changing optimize parameter of service's commit - method to its correct name: expungeDeletes. Also harded php unit - tests around commit. - - thanks to Liam O'Boyle and Olivier Ricordeau for patches for this - commit and the previous one for issue #51 - -2011-02-08 19:11 donovan.jimenez - - * Apache/Solr/Service.php, tests/Apache/Solr/ServiceTest.php: See - issue #51 - adding commitWithin parameter to addDocument and - addDocuments. Also hardened php unit tests for this functions - -2011-02-04 16:29 donovan.jimenez - - * Apache/Solr/Document.php, Apache/Solr/Exception.php, - Apache/Solr/HttpTransport/Abstract.php, - Apache/Solr/HttpTransport/Curl.php, - Apache/Solr/HttpTransport/CurlNoReuse.php, - Apache/Solr/HttpTransport/FileGetContents.php, - Apache/Solr/HttpTransport/Interface.php, - Apache/Solr/HttpTransport/Response.php, - Apache/Solr/HttpTransportException.php, - Apache/Solr/InvalidArgumentException.php, - Apache/Solr/NoServiceAvailableException.php, - Apache/Solr/ParserException.php, Apache/Solr/Response.php, - Apache/Solr/Service.php, Apache/Solr/Service/Balancer.php, - COPYING, tests/Apache/Solr/DocumentTest.php, - tests/Apache/Solr/HttpTransport/AbstractTest.php, - tests/Apache/Solr/HttpTransport/CurlNoReuseTest.php, - tests/Apache/Solr/HttpTransport/CurlTest.php, - tests/Apache/Solr/HttpTransport/FileGetContentsTest.php, - tests/Apache/Solr/HttpTransport/ResponseTest.php, - tests/Apache/Solr/HttpTransportExceptionTest.php, - tests/Apache/Solr/ResponseTest.php, - tests/Apache/Solr/Service/BalancerTest.php, - tests/Apache/Solr/ServiceAbstractTest.php, - tests/Apache/Solr/ServiceTest.php: Updating licence and copyright - texts in sources to reflect transition from Conduit IT to - Servigistics - -2010-11-02 20:16 donovan.jimenez - - * Apache/Solr/Service.php, Apache/Solr/Service/Balancer.php, - tests/Apache/Solr/ServiceAbstractTest.php, - tests/Apache/Solr/ServiceTest.php: See issue #55 - * Adding an Apache_Solr_Service::extractFromString method - * Adding Apache_Solr_Service_Balancer::extract and - Apache_Solr_Service_Balancer::extractFromString methods - -2010-10-21 15:23 donovan.jimenez - - * ., Apache/Solr/HttpTransport, - Apache/Solr/HttpTransport/Abstract.php, - Apache/Solr/HttpTransport/Curl.php, - Apache/Solr/HttpTransport/CurlNoReuse.php, - Apache/Solr/HttpTransport/FileGetContents.php, - Apache/Solr/HttpTransport/Interface.php, - Apache/Solr/HttpTransport/Response.php, Apache/Solr/Response.php, - Apache/Solr/Service.php, Apache/Solr/Service/Balancer.php, - COPYING, tests/Apache/Solr/DocumentTest.php, - tests/Apache/Solr/HttpTransport, - tests/Apache/Solr/HttpTransport/AbstractTest.php, - tests/Apache/Solr/HttpTransport/CurlNoReuseTest.php, - tests/Apache/Solr/HttpTransport/CurlTest.php, - tests/Apache/Solr/HttpTransport/FileGetContentsTest.php, - tests/Apache/Solr/HttpTransport/ResponseTest.php, - tests/Apache/Solr/HttpTransportExceptionTest.php, - tests/Apache/Solr/ResponseTest.php, - tests/Apache/Solr/Service/BalancerTest.php, - tests/Apache/Solr/Service/TestAll.php, - tests/Apache/Solr/ServiceAbstractTest.php, - tests/Apache/Solr/ServiceTest.php, tests/Apache/Solr/TestAll.php, - tests/phpunit.bootstrap.inc, tests/phpunit.xml, tests/run.php: - Merging the http_requests branch into trunk - - See issue #49 - Service can now have the way it makes HTTP - requests plugged in. - The only requirement is that the plugin implement the new - Apache_Solr_HttpTransport_Interface. There are initial - implementations for using - file_get_contents (what was used previously) and for using the - curl module. Much - thanks to Timo Schmidt for submitting an initial patch. - - If the user does not specifically provide a transport interface - instance, the - file get contents implementation will be used by default. - - There is a compatibility breaking change on the - Apache_Solr_Response - constructor. The Signature has changed. - - The getDefaultTimeout and setDefaultTimeout methods on the - Apache_Solr_Service - class are now deprecated. They simple pass through to the active - transport's - methods of the same name, and I'd rather the user manage it - there. - - Additionally, I have cleaned up and expanded the existing unit - tests - had to - change tests related to the breaking change, and added new ones - for the new - classes as well as expanding existing ones. They should now all - pass. curl tests - should only run if the curl module is enabled. file get contents - tests should - only run if allow_url_fopen is enabled. transport tests do rely - on an internet - connection at this time. - -2010-09-07 14:44 donovan.jimenez - - * Apache/Solr/Document.php: See issue #48, doing an isset check as - part of the magic get. Return null if not. - -2010-09-07 14:34 donovan.jimenez - - * Apache/Solr/Service.php: See issue #47, adding missing argument - to getFieldBoost call in Apache_Solr_Service::extract method - -2010-07-08 22:35 donovan.jimenez - - * Apache/Solr/Service.php: See issue #37 - adding a getter / - setting for the default timeout value. Still initially populated - with the default_socket_timeout ini setting - -2010-07-08 22:21 donovan.jimenez - - * Apache/Solr/Service.php: See issue #42 - Adding missing require - once for ParserException - -2010-04-24 00:44 donovan.jimenez - - * Apache/Solr/HttpTransportException.php, Apache/Solr/Service.php: - See issue #38 - Adding support for Solr Cell (tika) extraction - handler. Thanks to Liam O'Boyle for original patch. - -2010-03-22 23:10 donovan.jimenez - - * Apache/Solr/Service.php: See Issue #39 - send charset for POST - form encoded data so that the servlet container for solr will - interpret data correctly (will usually default to latin1) - -2010-03-22 23:06 donovan.jimenez - - * Apache/Solr/Service.php: Resolving Issue #40 - when using php - with all error output or using a code analyzer, the - http_response_header variable looks as though it won't be - initialized before being used. Initializing it to null to - alleviate the emitted warning. - -2010-03-10 00:28 donovan.jimenez - - * tests, tests/Apache, tests/Apache/Solr, - tests/Apache/Solr/DocumentTest.php, - tests/Apache/Solr/ResponseTest.php, tests/Apache/Solr/Service, - tests/Apache/Solr/Service/BalancerTest.php, - tests/Apache/Solr/Service/TestAll.php, - tests/Apache/Solr/ServiceTest.php, tests/Apache/Solr/TestAll.php, - tests/README, tests/phpunit.bootstrap.inc, tests/phpunit.xml, - tests/run.php: Adding some very dusty unit tests. They are not - complete, and some recent API changes may not be reflected in - them, but they are a start. - -2010-02-20 00:01 donovan.jimenez - - * Apache/Solr/Service/Balancer.php: See Issue #34 - synchronizing - Apache_Solr_Service_Balancer public methods with changes in - Apache_Solr_Service. Specifically, adding some missing optional - timeout parameters and adding the new deleteByMultipleIds method - -2010-02-19 23:47 donovan.jimenez - - * Apache/Solr/Response.php: See Issue #35 - implementing __isset - magic method on Apache_Solr_Response - -2010-02-19 23:36 donovan.jimenez - - * Apache/Solr/Document.php, Apache/Solr/Exception.php, - Apache/Solr/HttpTransportException.php, - Apache/Solr/InvalidArgumentException.php, - Apache/Solr/NoServiceAvailableException.php, - Apache/Solr/ParserException.php, Apache/Solr/Response.php, - Apache/Solr/Service.php, Apache/Solr/Service/Balancer.php: See - Issue #36 - fix usage of generic exceptions, thanks to dennis - vierkant for the patch. - -2009-12-10 03:51 donovan.jimenez - - * Apache/Solr/Service.php: Fixes issue #28 - Fixes typo in - setNamedListTreatment function name. Thanks to alex dunae - -2009-12-10 03:49 donovan.jimenez - - * Apache/Solr/Response.php: Fixes issue #27 - when parsing the JSON - data, add a check for null so we can throw an exception if the - response seems to be invalid. Thanks to thomas rabaix for the - suggestion. - -2009-11-21 02:07 donovan.jimenez - - * Apache/Solr/Service.php: see issue #23 - removing unused (by Sorl - JSON writer) and incorrect (version did not track with Solr - version) version parameter from all requests - -2009-11-21 02:02 donovan.jimenez - - * Apache/Solr/Service.php: Fixes #26 - Do a php version check - against 5.1.3 to determine whether brackets will be url encoded - by http_build_query function. Depending on the result of the - version check use the proper regex for fixing up the query string - before passing it to Solr - -2009-11-09 22:46 donovan.jimenez - - * Apache/Solr/Service.php: Fixes #20 - in previous fix, used - stream_context_set_params when I should have used - stream_context_set_option - -2009-11-09 22:08 donovan.jimenez - - * Apache/Solr/Service.php: Fixes #20 - Reusing a get and post - context for each request instead of creating a new stream context - for each. PHP does not provide a function to delete created - stream contexts and does not appear to clean them up when they go - out of scope, which leads to high memory usage when many solr - requests were issued (typically in indexing usage) - -2009-11-09 21:32 donovan.jimenez - - * Apache/Solr/Service.php: Fixes #21 - Adding method to delete by - multiple IDs. Thanks to pwolanin - -2009-08-12 14:08 donovan.jimenez - - * Apache/Solr/Response.php: The split function is deprecated as of - PHP 5.3. Furthermore, since none of my split's were using a regex - it is better to use explode anyway. Fixes #19 - -2009-08-04 18:23 donovan.jimenez - - * Apache/Solr/Response.php, Apache/Solr/Service.php: Removed todo's - about investigating Serialized PHP and PHP output writer usage. - I've made the decision to stick to usage of JSON output writer - until it can be proven that the other output writers are more - stable or provide a substantially faster implementation. Closes - issue #6 - -2009-08-04 17:53 donovan.jimenez - - * Apache/Solr/Document.php, Apache/Solr/Response.php, - Apache/Solr/Service.php, Apache/Solr/Service/Balancer.php: Adding - useful SVN metadata constants to each Apache_Solr class by svn - keyword substitution. Fixes issue #16 - -2009-08-04 17:14 donovan.jimenez - - * Apache/Solr/Service.php: Fixes issue #5 - Applying patch (with - minor changes) from mkalkbrenner to replace all control - characters in Apache_Solr_Document keys / values with spaces to - avoid an exception from Solr's XML Parser. - -2009-07-20 14:14 donovan.jimenez - - * Apache/Solr/Service.php: See issue #14 - * adding timeout parameters to all delete functions - -2009-05-11 14:51 donovan.jimenez - - * Apache/Solr/Service.php: See issue #8 - * Adding the ability to specify the HTTP method used for sending - a search query (GET or POST) - -2009-03-12 03:46 donovan.jimenez - - * Apache/Solr/Service.php: See - http://code.google.com/p/solr-php-client/issues/detail?id=4 - * Reworking Service::ping() to just use file_get_contents URL - wrappers like we do for other GET's and POST operations - * Reworked Service::_sendRawGet() and Service::_sendRawPost() to - create a new stream context each time. Used for controlled - request timeouts, headers, and POST information - -2009-01-29 00:49 donovan.jimenez - - * Apache/Solr/Document.php: See - http://code.google.com/p/solr-php-client/issues/detail?id=2 - - Attempting to fix null vs. false boost parameter value issue by - always casting to float value first. - - Needs tested. - -2009-01-28 17:11 donovan.jimenez - - * Apache/Solr/Service.php, Apache/Solr/Service/Balancer.php: See - http://code.google.com/p/solr-php-client/issues/detail?id=1 - - Changed require_once statements that expected the Solr Client - library to be on the include path into statements that use the - __FILE__ magic constant to do them as absolute paths. This should - get rid of the requirement for the user to change their include - path configuration or add the library to the include path at - runtime. - - Provided as a convenience for the user. - - -2009-01-22 04:01 donovan.jimenez - - * Apache/Solr/Document.php, Apache/Solr/Response.php, - Apache/Solr/Service.php, Apache/Solr/Service/Balancer.php, - COPYING: Updating license to New BSD for google code hosting. - Also updating copyright message - -2009-01-21 23:50 donovan.jimenez - - * Apache, Apache/Solr, Apache/Solr/Document.php, - Apache/Solr/Response.php, Apache/Solr/Service, - Apache/Solr/Service.php, Apache/Solr/Service/Balancer.php: - Importing Solr PHP client from last released zip file - -2008-11-26 00:26 - - * .: Initial directory structure. - diff --git a/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_Document.html b/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_Document.html deleted file mode 100644 index dd3ec0b3..00000000 --- a/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_Document.html +++ /dev/null @@ -1,901 +0,0 @@ - - - - - - Docs For Class Apache_Solr_Document - - - - -
-

Class Apache_Solr_Document

- - -
-
Description
- -
-

- Implements interfaces: -

    -
  • IteratorAggregate (internal interface)
-

- -

Holds Key / Value pairs that represent a Solr Document along with any associated boost values. 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 $fieldName => $fieldValue)
  2. -
  3.  {
  4. -
  5.  ...
  6. -
  7.  }
  8. -

-

- Located in /Document.php (line 58) -

- - -

-	
-			
-
- - - -
-
Class Constant Summary
- -
-
-
-  - SVN_ID = '$Id: Document.php 54 2011-02-04 16:29:18Z donovan.jimenez $' - -
-
-  - SVN_REVISION = '$Revision: 54 $' - -
-
-
-
- - -
-
Variable Summary
- -
-
-
- float - $_documentBoost -
-
- array - $_fieldBoosts -
-
- array - $_fields -
-
-
-
- - -
-
Method Summary
- -
-
- -
- void - addField - (string $key, mixed $value, [mixed $boost = false]) -
- -
- void - clear - () -
- -
- mixed - getBoost - () -
- -
- mixed - getField - (string $key) -
- -
- float - getFieldBoost - (string $key) -
- -
- array - getFieldBoosts - () -
- -
- array - getFieldNames - () -
- -
- array - getFieldValues - () -
- -
- void - getIterator - () -
- -
- void - setBoost - (mixed $boost) -
- -
- void - setField - (string $key, mixed $value, [mixed $boost = false]) -
- -
- void - setFieldBoost - (string $key, mixed $boost) -
- -
- void - setMultiValue - (string $key, string $value, [mixed $boost = false]) -
- -
- mixed - __get - (string $key) -
- -
- boolean - __isset - (string $key) -
- -
- void - __set - (string $key, mixed $value) -
- -
- void - __unset - (string $key) -
-
-
-
- - -
-
Variables
- -
- - -
- -
- - float - $_documentBoost - = false (line 75) - -
- - -

Document boost value

-
    -
  • access: protected
  • -
- - - - - -
- -
- -
- - array - $_fieldBoosts - = array() (line 89) - -
- - -

Document field boost values, indexed by name

-
    -
  • var: array of floats
  • -
  • access: protected
  • -
- - - - - -
- -
- -
- - array - $_fields - = array() (line 82) - -
- - -

Document field values, indexed by name

-
    -
  • access: protected
  • -
- - - - - -
- -
-
- - -
-
Methods
- -
- - -
- -
- addField (line 154) -
- - -

Add a value to a multi-valued field

-

NOTE: the solr XML format allows you to specify boosts PER value even though the underlying Lucene implementation only allows a boost per field. To remedy this, the final field boost value will be the product of all specified boosts on field values - this is similar to SolrJ's functionality.

  1.  $doc new Apache_Solr_Document();
  2. -
  3.  
  4. -
  5.  $doc->addField('foo''bar'2.0);
  6. -
  7.  $doc->addField('foo''baz'3.0);
  8. -
  9.  
  10. -
  11.  // resultant field boost will be 6!
  12. -
  13.  echo $doc->getFieldBoost('foo');
  14. -

-
    -
  • access: public
  • -
- -
- void - - addField - - (string $key, mixed $value, [mixed $boost = false]) -
- -
    -
  • - string - $key
  • -
  • - mixed - $value
  • -
  • - mixed - $boost: Use false for default boost, else cast to float that should be > 0 or will be treated as false
  • -
- - -
- -
- -
- clear (line 94) -
- - -

Clear all boosts and fields from this document

-
    -
  • access: public
  • -
- -
- void - - clear - - () -
- - - -
- -
- -
- getBoost (line 107) -
- - -

Get current document boost

-
    -
  • return: will be false for default, or else a float
  • -
  • access: public
  • -
- -
- mixed - - getBoost - - () -
- - - -
- -
- -
- getField (line 202) -
- - -

Get field information

-
    -
  • return: associative array of info if field exists, false otherwise
  • -
  • access: public
  • -
- -
- mixed - - getField - - (string $key) -
- -
    -
  • - string - $key
  • -
- - -
- -
- -
- getFieldBoost (line 237) -
- - -

Get the currently set field boost for a document field

-
    -
  • return: currently set field boost, false if one is not set
  • -
  • access: public
  • -
- -
- float - - getFieldBoost - - (string $key) -
- -
    -
  • - string - $key
  • -
- - -
- -
- -
- getFieldBoosts (line 267) -
- - -

Return current field boosts, indexed by field name

-
    -
  • access: public
  • -
- -
- array - - getFieldBoosts - - () -
- - - -
- -
- -
- getFieldNames (line 277) -
- - -

Get the names of all fields in this document

-
    -
  • access: public
  • -
- -
- array - - getFieldNames - - () -
- - - -
- -
- -
- getFieldValues (line 287) -
- - -

Get the values of all fields in this document

-
    -
  • access: public
  • -
- -
- array - - getFieldValues - - () -
- - - -
- -
- -
- getIterator (line 302) -
- - -

IteratorAggregate implementation function. Allows usage:

-

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

-
    -
  • access: public
  • -
- -
- void - - getIterator - - () -
- - -
-
Implementation of:
-
-
IteratorAggregate::getIterator
-
- -
- -
- -
- setBoost (line 117) -
- - -

Set document boost factor

-
    -
  • access: public
  • -
- -
- void - - setBoost - - (mixed $boost) -
- -
    -
  • - mixed - $boost: Use false for default boost, else cast to float that should be > 0 or will be treated as false
  • -
- - -
- -
- -
- setField (line 225) -
- - -

Set a field value. Multi-valued fields should be set as arrays or instead use the addField(...) function which will automatically make sure the field is an array.

-
    -
  • access: public
  • -
- -
- void - - setField - - (string $key, mixed $value, [mixed $boost = false]) -
- -
    -
  • - string - $key
  • -
  • - mixed - $value
  • -
  • - mixed - $boost: Use false for default boost, else cast to float that should be > 0 or will be treated as false
  • -
- - -
- -
- -
- setFieldBoost (line 248) -
- - -

Set the field boost for a document field

-
    -
  • access: public
  • -
- -
- void - - setFieldBoost - - (string $key, mixed $boost) -
- -
    -
  • - string - $key: field name for the boost
  • -
  • - mixed - $boost: Use false for default boost, else cast to float that should be > 0 or will be treated as false
  • -
- - -
- -
- -
- setMultiValue (line 191) -
- - -

Handle the array manipulation for a multi-valued field

-
    -
  • deprecated: Use addField(...) instead
  • -
  • access: public
  • -
- -
- void - - setMultiValue - - (string $key, string $value, [mixed $boost = false]) -
- -
    -
  • - string - $key
  • -
  • - string - $value
  • -
  • - mixed - $boost: Use false for default boost, else cast to float that should be > 0 or will be treated as false
  • -
- - -
- -
- -
- __get (line 315) -
- - -

Magic get for field values

-
    -
  • access: public
  • -
- -
- mixed - - __get - - (string $key) -
- -
    -
  • - string - $key
  • -
- - -
- -
- -
- __isset (line 348) -
- - -

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

-

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

-
    -
  • access: public
  • -
- -
- boolean - - __isset - - (string $key) -
- -
    -
  • - string - $key
  • -
- - -
- -
- -
- __set (line 333) -
- - -

Magic set for field values. Multi-valued fields should be set as arrays or instead use the addField(...) 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 362) -
- - -

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

-

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

-
    -
  • access: public
  • -
- -
- void - - __unset - - (string $key) -
- -
    -
  • - string - $key
  • -
- - -
- -
-
- - -
-
Class Constants
- -
- -
- -
- - - SVN_ID - = '$Id: Document.php 54 2011-02-04 16:29:18Z donovan.jimenez $' - (line 68) - -
- - -

SVN ID meta data for this class

- - -
- -
- -
- - - SVN_REVISION - = '$Revision: 54 $' - (line 63) - -
- - -

SVN Revision meta data for this class

- - -
- -
-
- -

- Documentation generated on Wed, 04 May 2011 11:01:13 -0400 by phpDocumentor 1.4.3 -

-
- \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_Exception.html b/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_Exception.html deleted file mode 100644 index 1ff8e678..00000000 --- a/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_Exception.html +++ /dev/null @@ -1,269 +0,0 @@ - - - - - - Docs For Class Apache_Solr_Exception - - - - -
-

Class Apache_Solr_Exception

- - -
-
Description
- -
- -

Copyright (c) 2007-2011, Servigistics, Inc.

-

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution.
  • Neither the name of Servigistics, Inc. nor the names of - its contributors may be used to endorse or promote products derived from - this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-
    -
  • author: Donovan Jimenez <djimenez@conduit-it.com>
  • -
  • version: $Id: Exception.php 54 2011-02-04 16:29:18Z donovan.jimenez $
  • -
  • copyright: Copyright 2007-2011 Servigistics, Inc. (http://servigistics.com)
  • -
  • license: New BSD
  • -
-

- Located in /Exception.php (line 39) -

- - -
Exception
-   |
-   --Apache_Solr_Exception
- -
-
- - -
-
Direct descendents
- -
- - - - - - - - - - - - - - - - - - - - - -
ClassDescription
Apache_Solr_HttpTransportException - Copyright (c) 2007-2011, Servigistics, Inc. -
Apache_Solr_ParserException - Copyright (c) 2007-2011, Servigistics, Inc. -
Apache_Solr_NoServiceAvailableException - Copyright (c) 2007-2011, Servigistics, Inc. -
Apache_Solr_InvalidArgumentException - Copyright (c) 2007-2011, Servigistics, Inc. -
-
-
- - -
-
Class Constant Summary
- -
-
-
-  - SVN_ID = '$Id: Exception.php 54 2011-02-04 16:29:18Z donovan.jimenez $' - -
-
-  - SVN_REVISION = '$Revision: 54 $' - -
-
-
-
- - - - -
-
Variables
- -
- -

Inherited Variables

- -

Inherited from Exception (Internal Class)

-
- - $code
-
- - $file
-
- - $line
-
- - $message
-
- - $previous
-
- - $string
-
- - $trace
-
-
- -
-
- - -
-
Methods
- -
- -

Inherited Methods

- - -

Inherited From Exception (Internal Class)

-
- constructor __construct ( [$message = ], [$code = ], [$previous = ] )
- getCode ( )
- getFile ( )
- getLine ( )
- getMessage ( )
- getPrevious ( )
- getTrace ( )
- getTraceAsString ( )
- __clone ( )
- __toString ( )
-
- -
-
- - -
-
Class Constants
- -
- -
- -
- - - SVN_ID - = '$Id: Exception.php 54 2011-02-04 16:29:18Z donovan.jimenez $' - (line 49) - -
- - -

SVN ID meta data for this class

- - -
- -
- -
- - - SVN_REVISION - = '$Revision: 54 $' - (line 44) - -
- - -

SVN Revision meta data for this class

- - -
- -
-
- -

- Documentation generated on Wed, 04 May 2011 11:01:13 -0400 by phpDocumentor 1.4.3 -

-
- \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_HttpTransportException.html b/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_HttpTransportException.html deleted file mode 100644 index d154edf8..00000000 --- a/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_HttpTransportException.html +++ /dev/null @@ -1,246 +0,0 @@ - - - - - - Docs For Class Apache_Solr_HttpTransportException - - - - -
-

Class Apache_Solr_HttpTransportException

- - -
-
Description
- -
- -

Copyright (c) 2007-2011, Servigistics, Inc.

-

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution.
  • Neither the name of Servigistics, Inc. nor the names of - its contributors may be used to endorse or promote products derived from - this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-
    -
  • author: Donovan Jimenez <djimenez@conduit-it.com>
  • -
  • version: $Id: HttpTransportException.php 54 2011-02-04 16:29:18Z donovan.jimenez $
  • -
  • copyright: Copyright 2007-2011 Servigistics, Inc. (http://servigistics.com)
  • -
  • license: New BSD
  • -
-

- Located in /HttpTransportException.php (line 39) -

- - -
Exception
-   |
-   --Apache_Solr_Exception
-      |
-      --Apache_Solr_HttpTransportException
- -
-
- - - -
-
Class Constant Summary
- -
-
-
-  - SVN_ID = '$Id: HttpTransportException.php 54 2011-02-04 16:29:18Z donovan.jimenez $' - -
-
-  - SVN_REVISION = '$Revision: 54 $' - -
-
-
-
- - - -
-
Method Summary
- -
-
- -
- Apache_Solr_HttpTransportException - __construct - (Apache_Solr_Response $response) -
- - -
-
-
- - - -
-
Methods
- -
- - -
- -
- Constructor __construct (line 63) -
- - -

HttpTransportException Constructor

-
    -
  • access: public
  • -
- -
- Apache_Solr_HttpTransportException - - __construct - - (Apache_Solr_Response $response) -
- - - - -
- -
- -
- getResponse (line 75) -
- - -

Get the response for which this exception was generated

-
    -
  • access: public
  • -
- -
- Apache_Solr_Response - - getResponse - - () -
- - - -
- -
-
- - -
-
Class Constants
- -
- -
- -
- - - SVN_ID - = '$Id: HttpTransportException.php 54 2011-02-04 16:29:18Z donovan.jimenez $' - (line 49) - -
- - -

SVN ID meta data for this class

- - -
- -
- -
- - - SVN_REVISION - = '$Revision: 54 $' - (line 44) - -
- - -

SVN Revision meta data for this class

- - -
-

Inherited Constants

- -

Inherited from Apache_Solr_Exception

-
- - - Apache_Solr_Exception::SVN_ID
-
- - - Apache_Solr_Exception::SVN_REVISION
-
-
- -
-
- -

- Documentation generated on Wed, 04 May 2011 11:01:14 -0400 by phpDocumentor 1.4.3 -

-
- \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_HttpTransport_Abstract.html b/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_HttpTransport_Abstract.html deleted file mode 100644 index b9f39cd0..00000000 --- a/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_HttpTransport_Abstract.html +++ /dev/null @@ -1,196 +0,0 @@ - - - - - - Docs For Class Apache_Solr_HttpTransport_Abstract - - - - -
-

Class Apache_Solr_HttpTransport_Abstract

- - -
-
Description
- -
-

- Implements interfaces: -

-

- -

Convenience class that implements the transport implementation. Can be extended by

-

real implementations to do some of the common book keeping

-
    -
  • abstract:
  • -
-

- Located in /HttpTransport/Abstract.php (line 43) -

- - -

-	
-			
-
- - -
-
Direct descendents
- -
- - - - - - - - - - - - - - - - - -
ClassDescription
Apache_Solr_HttpTransport_FileGetContents - HTTP Transport implemenation that uses the builtin http URL wrappers and file_get_contents -
Apache_Solr_HttpTransport_Curl - A Curl based HTTP transport. Uses a single curl session for all requests. -
Apache_Solr_HttpTransport_CurlNoReuse - An alternative Curl HTTP transport that opens and closes a curl session for every request. This isn't the recommended way to use curl, but some version of PHP have memory issues. -
-
-
- - - - -
-
Method Summary
- -
-
- -
- float - getDefaultTimeout - () -
- -
- void - setDefaultTimeout - (float $timeout) -
-
-
-
- - - -
-
Methods
- -
- - -
- -
- getDefaultTimeout (line 58) -
- - -

Get the current default timeout setting (initially the default_socket_timeout ini setting) in seconds

-
    -
  • access: public
  • -
- -
- float - - getDefaultTimeout - - () -
- - -
-
Implementation of:
-
-
Apache_Solr_HttpTransport_Interface::getDefaultTimeout()
-
Get the current default timeout for all HTTP requests
-
- -
- -
- -
- setDefaultTimeout (line 80) -
- - -

Set the current default timeout for all HTTP requests

-
    -
  • access: public
  • -
- -
- void - - setDefaultTimeout - - (float $timeout) -
- -
    -
  • - float - $timeout
  • -
- -
-
Implementation of:
-
-
Apache_Solr_HttpTransport_Interface::setDefaultTimeout()
-
Set the current default timeout for all HTTP requests
-
- -
- -
-
- - -

- Documentation generated on Wed, 04 May 2011 11:01:08 -0400 by phpDocumentor 1.4.3 -

-
- \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_HttpTransport_Curl.html b/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_HttpTransport_Curl.html deleted file mode 100644 index e21f6048..00000000 --- a/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_HttpTransport_Curl.html +++ /dev/null @@ -1,336 +0,0 @@ - - - - - - Docs For Class Apache_Solr_HttpTransport_Curl - - - - -
-

Class Apache_Solr_HttpTransport_Curl

- - -
-
Description
- -
- -

A Curl based HTTP transport. Uses a single curl session for all requests.

-

- Located in /HttpTransport/Curl.php (line 45) -

- - -
Apache_Solr_HttpTransport_Abstract
-   |
-   --Apache_Solr_HttpTransport_Curl
- -
-
- - - -
-
Class Constant Summary
- -
-
-
-  - SVN_ID = '$Id:$' - -
-
-  - SVN_REVISION = '$Revision:$' - -
-
-
-
- - - -
-
Method Summary
- -
-
- -
- Apache_Solr_HttpTransport_Curl - __construct - () -
- -
- void - __destruct - () -
- -
- void - performGetRequest - ( $url, [ $timeout = false]) -
- -
- void - performHeadRequest - ( $url, [ $timeout = false]) -
- -
- void - performPostRequest - ( $url,  $postData,  $contentType, [ $timeout = false]) -
-
-
-
- - - -
-
Methods
- -
- - -
- -
- Constructor __construct (line 67) -
- - -

Initializes a curl session

-
    -
  • access: public
  • -
- -
- Apache_Solr_HttpTransport_Curl - - __construct - - () -
- - - -
- -
- -
- Destructor __destruct (line 88) -
- - -

Closes a curl session

- -
- void - - __destruct - - () -
- - - -
- -
- -
- performGetRequest (line 94) -
- - -
    -
  • access: public
  • -
- -
- void - - performGetRequest - - ( $url, [ $timeout = false]) -
- -
    -
  • - - $url
  • -
  • - - $timeout
  • -
- - -
- -
- -
- performHeadRequest (line 128) -
- - -
    -
  • access: public
  • -
- -
- void - - performHeadRequest - - ( $url, [ $timeout = false]) -
- -
    -
  • - - $url
  • -
  • - - $timeout
  • -
- - -
- -
- -
- performPostRequest (line 159) -
- - -
    -
  • access: public
  • -
- -
- void - - performPostRequest - - ( $url,  $postData,  $contentType, [ $timeout = false]) -
- -
    -
  • - - $url
  • -
  • - - $postData
  • -
  • - - $contentType
  • -
  • - - $timeout
  • -
- - -
-

Inherited Methods

- - -

Inherited From Apache_Solr_HttpTransport_Abstract

-
- Apache_Solr_HttpTransport_Abstract::getDefaultTimeout()
- Apache_Solr_HttpTransport_Abstract::setDefaultTimeout()
-
- -
-
- - -
-
Class Constants
- -
- -
- -
- - - SVN_ID - = '$Id:$' - (line 55) - -
- - -

SVN ID meta data for this class

- - -
- -
- -
- - - SVN_REVISION - = '$Revision:$' - (line 50) - -
- - -

SVN Revision meta data for this class

- - -
- -
-
- -

- Documentation generated on Wed, 04 May 2011 11:01:12 -0400 by phpDocumentor 1.4.3 -

-
- \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_HttpTransport_CurlNoReuse.html b/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_HttpTransport_CurlNoReuse.html deleted file mode 100644 index 9179a0d1..00000000 --- a/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_HttpTransport_CurlNoReuse.html +++ /dev/null @@ -1,279 +0,0 @@ - - - - - - Docs For Class Apache_Solr_HttpTransport_CurlNoReuse - - - - -
-

Class Apache_Solr_HttpTransport_CurlNoReuse

- - -
-
Description
- -
- -

An alternative Curl HTTP transport that opens and closes a curl session for every request. This isn't the recommended way to use curl, but some version of PHP have memory issues.

-

- Located in /HttpTransport/CurlNoReuse.php (line 47) -

- - -
Apache_Solr_HttpTransport_Abstract
-   |
-   --Apache_Solr_HttpTransport_CurlNoReuse
- -
-
- - - -
-
Class Constant Summary
- -
-
-
-  - SVN_ID = '$Id:$' - -
-
-  - SVN_REVISION = '$Revision:$' - -
-
-
-
- - - -
-
Method Summary
- -
-
- -
- void - performGetRequest - ( $url, [ $timeout = false]) -
- -
- void - performHeadRequest - ( $url, [ $timeout = false]) -
- -
- void - performPostRequest - ( $url,  $postData,  $contentType, [ $timeout = false]) -
-
-
-
- - - -
-
Methods
- -
- - -
- -
- performGetRequest (line 59) -
- - -
    -
  • access: public
  • -
- -
- void - - performGetRequest - - ( $url, [ $timeout = false]) -
- -
    -
  • - - $url
  • -
  • - - $timeout
  • -
- - -
- -
- -
- performHeadRequest (line 101) -
- - -
    -
  • access: public
  • -
- -
- void - - performHeadRequest - - ( $url, [ $timeout = false]) -
- -
    -
  • - - $url
  • -
  • - - $timeout
  • -
- - -
- -
- -
- performPostRequest (line 146) -
- - -
    -
  • access: public
  • -
- -
- void - - performPostRequest - - ( $url,  $postData,  $contentType, [ $timeout = false]) -
- -
    -
  • - - $url
  • -
  • - - $postData
  • -
  • - - $contentType
  • -
  • - - $timeout
  • -
- - -
-

Inherited Methods

- - -

Inherited From Apache_Solr_HttpTransport_Abstract

-
- Apache_Solr_HttpTransport_Abstract::getDefaultTimeout()
- Apache_Solr_HttpTransport_Abstract::setDefaultTimeout()
-
- -
-
- - -
-
Class Constants
- -
- -
- -
- - - SVN_ID - = '$Id:$' - (line 57) - -
- - -

SVN ID meta data for this class

- - -
- -
- -
- - - SVN_REVISION - = '$Revision:$' - (line 52) - -
- - -

SVN Revision meta data for this class

- - -
- -
-
- -

- Documentation generated on Wed, 04 May 2011 11:01:13 -0400 by phpDocumentor 1.4.3 -

-
- \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_HttpTransport_FileGetContents.html b/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_HttpTransport_FileGetContents.html deleted file mode 100644 index a43013f6..00000000 --- a/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_HttpTransport_FileGetContents.html +++ /dev/null @@ -1,309 +0,0 @@ - - - - - - Docs For Class Apache_Solr_HttpTransport_FileGetContents - - - - -
-

Class Apache_Solr_HttpTransport_FileGetContents

- - -
-
Description
- -
- -

HTTP Transport implemenation that uses the builtin http URL wrappers and file_get_contents

-

- Located in /HttpTransport/FileGetContents.php (line 45) -

- - -
Apache_Solr_HttpTransport_Abstract
-   |
-   --Apache_Solr_HttpTransport_FileGetContents
- -
-
- - - -
-
Class Constant Summary
- -
-
-
-  - SVN_ID = '$Id: $' - -
-
-  - SVN_REVISION = '$Revision: $' - -
-
-
-
- - - -
-
Method Summary
- -
-
- -
- Apache_Solr_HttpTransport_FileGetContents - __construct - () -
- -
- void - performGetRequest - ( $url, [ $timeout = false]) -
- -
- void - performHeadRequest - ( $url, [ $timeout = false]) -
- -
- void - performPostRequest - ( $url,  $rawPost,  $contentType, [ $timeout = false]) -
-
-
-
- - - -
-
Methods
- -
- - -
- -
- Constructor __construct (line 67) -
- - -

Initializes our reuseable get and post stream contexts

-
    -
  • access: public
  • -
- -
- Apache_Solr_HttpTransport_FileGetContents - - __construct - - () -
- - - -
- -
- -
- performGetRequest (line 74) -
- - -
    -
  • access: public
  • -
- -
- void - - performGetRequest - - ( $url, [ $timeout = false]) -
- -
    -
  • - - $url
  • -
  • - - $timeout
  • -
- - -
- -
- -
- performHeadRequest (line 100) -
- - -
    -
  • access: public
  • -
- -
- void - - performHeadRequest - - ( $url, [ $timeout = false]) -
- -
    -
  • - - $url
  • -
  • - - $timeout
  • -
- - -
- -
- -
- performPostRequest (line 132) -
- - -
    -
  • access: public
  • -
- -
- void - - performPostRequest - - ( $url,  $rawPost,  $contentType, [ $timeout = false]) -
- -
    -
  • - - $url
  • -
  • - - $rawPost
  • -
  • - - $contentType
  • -
  • - - $timeout
  • -
- - -
-

Inherited Methods

- - -

Inherited From Apache_Solr_HttpTransport_Abstract

-
- Apache_Solr_HttpTransport_Abstract::getDefaultTimeout()
- Apache_Solr_HttpTransport_Abstract::setDefaultTimeout()
-
- -
-
- - -
-
Class Constants
- -
- -
- -
- - - SVN_ID - = '$Id: $' - (line 55) - -
- - -

SVN ID meta data for this class

- - -
- -
- -
- - - SVN_REVISION - = '$Revision: $' - (line 50) - -
- - -

SVN Revision meta data for this class

- - -
- -
-
- -

- Documentation generated on Wed, 04 May 2011 11:01:14 -0400 by phpDocumentor 1.4.3 -

-
- \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_HttpTransport_Interface.html b/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_HttpTransport_Interface.html deleted file mode 100644 index c8e50aac..00000000 --- a/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_HttpTransport_Interface.html +++ /dev/null @@ -1,260 +0,0 @@ - - - - - - Docs For Class Apache_Solr_HttpTransport_Interface - - - - -
-

Interface Apache_Solr_HttpTransport_Interface

- - -
-
Description
- -
- -

Interface that all Transport (HTTP Requester) implementations must implement. These

-

Implementations can then be plugged into the Service instance in order to user their the desired method for making HTTP requests

-

- Located in /HttpTransport/Interface.php (line 47) -

- - -

-	
-			
-
- - - - - -
-
Method Summary
- -
-
- -
- float - getDefaultTimeout - () -
- -
- Apache_Solr_HttpTransport_Response - performGetRequest - (string $url, [float $timeout = false]) -
- -
- Apache_Solr_HttpTransport_Response - performHeadRequest - (string $url, [float $timeout = false]) -
- -
- Apache_Solr_HttpTransport_Response - performPostRequest - (string $url, string $rawPost, string $contentType, [float $timeout = false]) -
- -
- void - setDefaultTimeout - (float $timeout) -
-
-
-
- - - -
-
Methods
- -
- - -
- -
- getDefaultTimeout (line 54) -
- - -

Get the current default timeout for all HTTP requests

-
    -
  • access: public
  • -
- -
- float - - getDefaultTimeout - - () -
- - - -
- -
- -
- performGetRequest (line 71) -
- - -

Perform a GET HTTP operation with an optional timeout and return the response contents, use getLastResponseHeaders to retrieve HTTP headers

-
    -
  • return: HTTP response
  • -
  • access: public
  • -
- -
- Apache_Solr_HttpTransport_Response - - performGetRequest - - (string $url, [float $timeout = false]) -
- -
    -
  • - string - $url
  • -
  • - float - $timeout
  • -
- - -
- -
- -
- performHeadRequest (line 81) -
- - -

Perform a HEAD HTTP operation with an optional timeout and return the response headers - NOTE: head requests have no response body

-
    -
  • return: HTTP response
  • -
  • access: public
  • -
- -
- Apache_Solr_HttpTransport_Response - - performHeadRequest - - (string $url, [float $timeout = false]) -
- -
    -
  • - string - $url
  • -
  • - float - $timeout
  • -
- - -
- -
- -
- performPostRequest (line 93) -
- - -

Perform a POST HTTP operation with an optional timeout and return the response contents, use getLastResponseHeaders to retrieve HTTP headers

-
    -
  • return: HTTP response
  • -
  • access: public
  • -
- -
- Apache_Solr_HttpTransport_Response - - performPostRequest - - (string $url, string $rawPost, string $contentType, [float $timeout = false]) -
- -
    -
  • - string - $url
  • -
  • - string - $rawPost
  • -
  • - string - $contentType
  • -
  • - float - $timeout
  • -
- - -
- -
- -
- setDefaultTimeout (line 61) -
- - -

Set the current default timeout for all HTTP requests

-
    -
  • access: public
  • -
- -
- void - - setDefaultTimeout - - (float $timeout) -
- -
    -
  • - float - $timeout
  • -
- - -
- -
-
- - -

- Documentation generated on Wed, 04 May 2011 11:01:15 -0400 by phpDocumentor 1.4.3 -

-
- \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_HttpTransport_Response.html b/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_HttpTransport_Response.html deleted file mode 100644 index 4f0bfd21..00000000 --- a/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_HttpTransport_Response.html +++ /dev/null @@ -1,298 +0,0 @@ - - - - - - Docs For Class Apache_Solr_HttpTransport_Response - - - - -
-

Class Apache_Solr_HttpTransport_Response

- - -
-
Description
- -
- -

Represents the required pieces of an HTTP response provided by HTTP transport

-

implementations and then consumed by the Apache_Solr_Response class which provides decoding

-

- Located in /HttpTransport/Response.php (line 44) -

- - -

-	
-			
-
- - - - - -
-
Method Summary
- -
-
- -
- static string - getDefaultStatusMessage - ( $statusCode) -
- -
- Apache_Solr_HttpTransport_Response - __construct - (integer $statusCode, string $contentType, string $responseBody) -
- -
- string - getBody - () -
- -
- string - getEncoding - () -
- -
- string - getMimeType - () -
- -
- integer - getStatusCode - () -
- -
- string - getStatusMessage - () -
-
-
-
- - - -
-
Methods
- -
- - -
- -
- static getDefaultStatusMessage (line 112) -
- - -

Get the HTTP status message based on status code

-
    -
  • access: public
  • -
- -
- static string - - getDefaultStatusMessage - - ( $statusCode) -
- -
    -
  • - - $statusCode
  • -
- - -
- -
- -
- Constructor __construct (line 166) -
- - -

Construct a HTTP transport response

-
    -
  • access: public
  • -
- -
- Apache_Solr_HttpTransport_Response - - __construct - - (integer $statusCode, string $contentType, string $responseBody) -
- -
    -
  • - integer - $statusCode: The HTTP status code
  • -
  • - string - $contentType: The VALUE of the Content-Type HTTP header
  • -
  • - string - $responseBody: The body of the HTTP response
  • -
- - -
- -
- -
- getBody (line 251) -
- - -

Get the raw response body

-
    -
  • access: public
  • -
- -
- string - - getBody - - () -
- - - -
- -
- -
- getEncoding (line 241) -
- - -

Get the charset encoding of the response body.

-
    -
  • access: public
  • -
- -
- string - - getEncoding - - () -
- - - -
- -
- -
- getMimeType (line 231) -
- - -

Get the mimetype of the response body

-
    -
  • access: public
  • -
- -
- string - - getMimeType - - () -
- - - -
- -
- -
- getStatusCode (line 211) -
- - -

Get the status code of the response

-
    -
  • access: public
  • -
- -
- integer - - getStatusCode - - () -
- - - -
- -
- -
- getStatusMessage (line 221) -
- - -

Get the status message of the response

-
    -
  • access: public
  • -
- -
- string - - getStatusMessage - - () -
- - - -
- -
-
- - -

- Documentation generated on Wed, 04 May 2011 11:01:16 -0400 by phpDocumentor 1.4.3 -

-
- \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_InvalidArgumentException.html b/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_InvalidArgumentException.html deleted file mode 100644 index 49d57ee4..00000000 --- a/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_InvalidArgumentException.html +++ /dev/null @@ -1,144 +0,0 @@ - - - - - - Docs For Class Apache_Solr_InvalidArgumentException - - - - -
-

Class Apache_Solr_InvalidArgumentException

- - -
-
Description
- -
- -

Copyright (c) 2007-2011, Servigistics, Inc.

-

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution.
  • Neither the name of Servigistics, Inc. nor the names of - its contributors may be used to endorse or promote products derived from - this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-
    -
  • author: Donovan Jimenez <djimenez@conduit-it.com>
  • -
  • version: $Id: InvalidArgumentException.php 54 2011-02-04 16:29:18Z donovan.jimenez $
  • -
  • copyright: Copyright 2007-2011 Servigistics, Inc. (http://servigistics.com)
  • -
  • license: New BSD
  • -
-

- Located in /InvalidArgumentException.php (line 39) -

- - -
Exception
-   |
-   --Apache_Solr_Exception
-      |
-      --Apache_Solr_InvalidArgumentException
- -
-
- - - -
-
Class Constant Summary
- -
-
-
-  - SVN_ID = '$Id: InvalidArgumentException.php 54 2011-02-04 16:29:18Z donovan.jimenez $' - -
-
-  - SVN_REVISION = '$Revision: 54 $' - -
-
-
-
- - - - - - -
-
Class Constants
- -
- -
- -
- - - SVN_ID - = '$Id: InvalidArgumentException.php 54 2011-02-04 16:29:18Z donovan.jimenez $' - (line 49) - -
- - -

SVN ID meta data for this class

- - -
- -
- -
- - - SVN_REVISION - = '$Revision: 54 $' - (line 44) - -
- - -

SVN Revision meta data for this class

- - -
-

Inherited Constants

- -

Inherited from Apache_Solr_Exception

-
- - - Apache_Solr_Exception::SVN_ID
-
- - - Apache_Solr_Exception::SVN_REVISION
-
-
- -
-
- -

- Documentation generated on Wed, 04 May 2011 11:01:15 -0400 by phpDocumentor 1.4.3 -

-
- \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_NoServiceAvailableException.html b/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_NoServiceAvailableException.html deleted file mode 100644 index 402d18b6..00000000 --- a/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_NoServiceAvailableException.html +++ /dev/null @@ -1,144 +0,0 @@ - - - - - - Docs For Class Apache_Solr_NoServiceAvailableException - - - - -
-

Class Apache_Solr_NoServiceAvailableException

- - -
-
Description
- -
- -

Copyright (c) 2007-2011, Servigistics, Inc.

-

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution.
  • Neither the name of Servigistics, Inc. nor the names of - its contributors may be used to endorse or promote products derived from - this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-
    -
  • author: Donovan Jimenez <djimenez@conduit-it.com>
  • -
  • version: $Id: NoServiceAvailableException.php 54 2011-02-04 16:29:18Z donovan.jimenez $
  • -
  • copyright: Copyright 2007-2011 Servigistics, Inc. (http://servigistics.com)
  • -
  • license: New BSD
  • -
-

- Located in /NoServiceAvailableException.php (line 39) -

- - -
Exception
-   |
-   --Apache_Solr_Exception
-      |
-      --Apache_Solr_NoServiceAvailableException
- -
-
- - - -
-
Class Constant Summary
- -
-
-
-  - SVN_ID = '$Id: NoServiceAvailableException.php 54 2011-02-04 16:29:18Z donovan.jimenez $' - -
-
-  - SVN_REVISION = '$Revision: 54 $' - -
-
-
-
- - - - - - -
-
Class Constants
- -
- -
- -
- - - SVN_ID - = '$Id: NoServiceAvailableException.php 54 2011-02-04 16:29:18Z donovan.jimenez $' - (line 49) - -
- - -

SVN ID meta data for this class

- - -
- -
- -
- - - SVN_REVISION - = '$Revision: 54 $' - (line 44) - -
- - -

SVN Revision meta data for this class

- - -
-

Inherited Constants

- -

Inherited from Apache_Solr_Exception

-
- - - Apache_Solr_Exception::SVN_ID
-
- - - Apache_Solr_Exception::SVN_REVISION
-
-
- -
-
- -

- Documentation generated on Wed, 04 May 2011 11:01:15 -0400 by phpDocumentor 1.4.3 -

-
- \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_ParserException.html b/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_ParserException.html deleted file mode 100644 index a751d0d9..00000000 --- a/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_ParserException.html +++ /dev/null @@ -1,144 +0,0 @@ - - - - - - Docs For Class Apache_Solr_ParserException - - - - -
-

Class Apache_Solr_ParserException

- - -
-
Description
- -
- -

Copyright (c) 2007-2011, Servigistics, Inc.

-

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution.
  • Neither the name of Servigistics, Inc. nor the names of - its contributors may be used to endorse or promote products derived from - this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-
    -
  • author: Donovan Jimenez <djimenez@conduit-it.com>
  • -
  • version: $Id: ParserException.php 54 2011-02-04 16:29:18Z donovan.jimenez $
  • -
  • copyright: Copyright 2007-2011 Servigistics, Inc. (http://servigistics.com)
  • -
  • license: New BSD
  • -
-

- Located in /ParserException.php (line 39) -

- - -
Exception
-   |
-   --Apache_Solr_Exception
-      |
-      --Apache_Solr_ParserException
- -
-
- - - -
-
Class Constant Summary
- -
-
-
-  - SVN_ID = '$Id: ParserException.php 54 2011-02-04 16:29:18Z donovan.jimenez $' - -
-
-  - SVN_REVISION = '$Revision: 54 $' - -
-
-
-
- - - - - - -
-
Class Constants
- -
- -
- -
- - - SVN_ID - = '$Id: ParserException.php 54 2011-02-04 16:29:18Z donovan.jimenez $' - (line 49) - -
- - -

SVN ID meta data for this class

- - -
- -
- -
- - - SVN_REVISION - = '$Revision: 54 $' - (line 44) - -
- - -

SVN Revision meta data for this class

- - -
-

Inherited Constants

- -

Inherited from Apache_Solr_Exception

-
- - - Apache_Solr_Exception::SVN_ID
-
- - - Apache_Solr_Exception::SVN_REVISION
-
-
- -
-
- -

- Documentation generated on Wed, 04 May 2011 11:01:15 -0400 by phpDocumentor 1.4.3 -

-
- \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_Response.html b/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_Response.html deleted file mode 100644 index 4ae52838..00000000 --- a/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_Response.html +++ /dev/null @@ -1,621 +0,0 @@ - - - - - - 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.

-

- Located in /Response.php (line 48) -

- - -

-	
-			
-
- - - -
-
Class Constant Summary
- -
-
-
-  - SVN_ID = '$Id: Response.php 54 2011-02-04 16:29:18Z donovan.jimenez $' - -
-
-  - SVN_REVISION = '$Revision: 54 $' - -
-
-
-
- - -
-
Variable Summary
- -
-
- -
- boolean - $_createDocuments -
-
- boolean - $_isParsed -
-
- mixed - $_parsedData -
- -
-
-
- - -
-
Method Summary
- -
-
- -
- Apache_Solr_HttpTransport_Response - __construct - (Apache_Solr_HttpTransport_Response $response, [boolean $createDocuments = true], [boolean $collapseSingleValueArrays = true]) -
- -
- string - getEncoding - () -
- -
- integer - getHttpStatus - () -
- -
- string - getHttpStatusMessage - () -
- -
- string - getRawResponse - () -
- -
- string - getType - () -
- -
- void - _parseData - () -
- -
- mixed - __get - (string $key) -
- -
- boolean - __isset - (string $key) -
-
-
-
- - -
-
Variables
- -
- - -
- -
- - mixed - $_collapseSingleValueArrays - = true (line 88) - -
- - -
    -
  • access: protected
  • -
- - - - - -
- -
- -
- - boolean - $_createDocuments - = true (line 87) - -
- - -

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

-
    -
  • access: protected
  • -
- - - - - -
- -
- -
- - boolean - $_isParsed - = false (line 72) - -
- - -

Whether the raw response has been parsed

-
    -
  • access: protected
  • -
- - - - - -
- -
- -
- - mixed - $_parsedData - (line 79) - -
- - -

Parsed representation of the data

-
    -
  • access: protected
  • -
- - - - - -
- -
- -
- - Apache_Solr_HttpTransport_Response - $_response - (line 65) - -
- - -

Holds the raw response used in construction

-
    -
  • var: HTTP response
  • -
  • access: protected
  • -
- - - - - -
- -
-
- - -
-
Methods
- -
- - -
- -
- Constructor __construct (line 97) -
- - -

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

-
    -
  • return: HTTP response
  • -
  • access: public
  • -
- -
- Apache_Solr_HttpTransport_Response - - __construct - - (Apache_Solr_HttpTransport_Response $response, [boolean $createDocuments = true], [boolean $collapseSingleValueArrays = true]) -
- -
    -
  • - 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
  • -
  • - Apache_Solr_HttpTransport_Response - $response
  • -
- - -
- -
- -
- getEncoding (line 139) -
- - -

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

-
    -
  • access: public
  • -
- -
- string - - getEncoding - - () -
- - - -
- -
- -
- getHttpStatus (line 109) -
- - -

Get the HTTP status code

-
    -
  • access: public
  • -
- -
- integer - - getHttpStatus - - () -
- - - -
- -
- -
- getHttpStatusMessage (line 119) -
- - -

Get the HTTP status message of the response

-
    -
  • access: public
  • -
- -
- string - - getHttpStatusMessage - - () -
- - - -
- -
- -
- getRawResponse (line 149) -
- - -

Get the raw response as it was given to this object

-
    -
  • access: public
  • -
- -
- string - - getRawResponse - - () -
- - - -
- -
- -
- getType (line 129) -
- - -

Get content type of this Solr response

-
    -
  • access: public
  • -
- -
- string - - getType - - () -
- - - -
- -
- -
- _parseData (line 198) -
- - -

Parse the raw response into the parsed_data array for access

-
    -
  • throws: Apache_Solr_ParserException If the data could not be parsed
  • -
  • access: protected
  • -
- -
- void - - _parseData - - () -
- - - -
- -
- -
- __get (line 160) -
- - -

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

-
    -
  • access: public
  • -
- -
- mixed - - __get - - (string $key) -
- -
    -
  • - string - $key
  • -
- - -
- -
- -
- __isset (line 182) -
- - -

Magic function for isset function on parsed data

-
    -
  • access: public
  • -
- -
- boolean - - __isset - - (string $key) -
- -
    -
  • - string - $key
  • -
- - -
- -
-
- - -
-
Class Constants
- -
- -
- -
- - - SVN_ID - = '$Id: Response.php 54 2011-02-04 16:29:18Z donovan.jimenez $' - (line 58) - -
- - -

SVN ID meta data for this class

- - -
- -
- -
- - - SVN_REVISION - = '$Revision: 54 $' - (line 53) - -
- - -

SVN Revision meta data for this class

- - -
- -
-
- -

- Documentation generated on Wed, 04 May 2011 11:01:15 -0400 by phpDocumentor 1.4.3 -

-
- \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_Service.html b/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_Service.html deleted file mode 100644 index aff68bee..00000000 --- a/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_Service.html +++ /dev/null @@ -1,2473 +0,0 @@ - - - - - - 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'010array('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 86) -

- - -

-	
-			
-
- - - -
-
Class Constant Summary
- -
-
-
-  - EXTRACT_SERVLET = 'update/extract' - -
-
-  - METHOD_GET = 'GET' - -
-
-  - METHOD_POST = 'POST' - -
-
-  - NAMED_LIST_FLAT = 'flat' - -
-
-  - NAMED_LIST_MAP = 'map' - -
-
-  - PING_SERVLET = 'admin/ping' - -
-
-  - SEARCH_SERVLET = 'select' - -
-
-  - SOLR_WRITER = 'json' - -
-
-  - SVN_ID = '$Id: Service.php 59 2011-02-08 20:38:59Z donovan.jimenez $' - -
-
-  - SVN_REVISION = '$Revision: 59 $' - -
-
-  - THREADS_SERVLET = 'admin/threads' - -
-
-  - UPDATE_SERVLET = 'update' - -
-
-
-
- - -
-
Variable Summary
- -
-
- -
- boolean - $_createDocuments -
-
- string - $_host -
- -
- string - $_namedListTreatment -
-
- mixed - $_path -
-
- string - $_pingUrl -
-
- mixed - $_port -
- -
- string - $_queryDelimiter -
- -
- mixed - $_searchUrl -
-
- mixed - $_threadsUrl -
-
- mixed - $_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], [integer $commitWithin = 0]) -
- -
- Apache_Solr_Response - addDocuments - (array $documents, [boolean $allowDups = false], [boolean $overwritePending = true], [boolean $overwriteCommitted = true], [integer $commitWithin = 0]) -
- -
- Apache_Solr_Response - commit - ([boolean $expungeDeletes = false], [boolean $waitFlush = true], [boolean $waitSearcher = true], [float $timeout = 3600]) -
- -
- Apache_Solr_Response - delete - (string $rawPost, [float $timeout = 3600]) -
- -
- Apache_Solr_Response - deleteById - (string $id, [boolean $fromPending = true], [boolean $fromCommitted = true], [float $timeout = 3600]) -
- -
- Apache_Solr_Response - deleteByMultipleIds - (array $ids, [boolean $fromPending = true], [boolean $fromCommitted = true], [float $timeout = 3600]) -
- -
- Apache_Solr_Response - deleteByQuery - (string $rawQuery, [boolean $fromPending = true], [boolean $fromCommitted = true], [float $timeout = 3600]) -
- -
- Apache_Solr_Response - extract - (string $file, [array $params = array()], [Apache_Solr_Document $document = null], [string $mimetype = 'application/octet-stream']) -
- -
- Apache_Solr_Response - extractFromString - (string $data, [array $params = array()], [Apache_Solr_Document $document = null], [string $mimetype = 'application/octet-stream']) -
- -
- Apache_Solr_Response - extractFromUrl - (string $url, [array $params = array()], [Apache_Solr_Document $document = null], [string $mimetype = 'application/octet-stream']) -
- -
- boolean - getCollapseSingleValueArrays - () -
- -
- boolean - getCreateDocuments - () -
- -
- float - getDefaultTimeout - () -
- -
- string - getHost - () -
- -
- HttpTransportInterface - getHttpTransport - () -
- -
- string - getNamedListTreatment - () -
- -
- string - getPath - () -
- -
- integer - getPort - () -
- -
- Apache_Solr_Service - __construct - ([string $host = 'localhost'], [string $port = 8180], [string $path = '/solr/'], [Apache_Solr_HttpTransport_Interface $httpTransport = false]) -
- -
- 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()], [string $method = self::METHOD_GET]) -
- -
- void - setCollapseSingleValueArrays - (boolean $collapseSingleValueArrays) -
- -
- void - setCreateDocuments - (boolean $createDocuments) -
- -
- void - setDefaultTimeout - (float $timeout) -
- -
- void - setHost - (string $host) -
- -
- void - setHttpTransport - (Apache_Solr_HttpTransport_Interface $httpTransport) -
- -
- void - setNamedListTreatment - (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 - _generateQueryString - ( $params) -
- -
- 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']) -
- -
- string - _stripCtrlChars - (string $string) -
-
-
-
- - -
-
Variables
- -
- - -
- -
- - boolean - $_collapseSingleValueArrays - = true (line 145) - -
- - -

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 137) - -
- - -

Whether Apache_Solr_Response objects should create Apache_Solr_Documents in the returned parsed data

-
    -
  • access: protected
  • -
- - - - - -
- -
- -
- - string - $_host - (line 129) - -
- - -

Server identification strings

-
    -
  • access: protected
  • -
- - - - - -
- -
- -
- - Apache_Solr_HttpTransport_Interface - $_httpTransport - = false (line 182) - -
- - -

HTTP Transport implementation (pluggable)

-
    -
  • access: protected
  • -
- - - - - -
- -
- -
- - string - $_namedListTreatment - = self::NAMED_LIST_MAP (line 153) - -
- - -

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 129) - -
- - -
    -
  • access: protected
  • -
- - - - - -
- -
- -
- - string - $_pingUrl - (line 168) - -
- - -

Constructed servlet full path URLs

-
    -
  • access: protected
  • -
- - - - - -
- -
- -
- - mixed - $_port - (line 129) - -
- - -
    -
  • access: protected
  • -
- - - - - -
- -
- -
- - mixed - $_queryBracketsEscaped - = true (line 161) - -
- - -
    -
  • access: protected
  • -
- - - - - -
- -
- -
- - string - $_queryDelimiter - = '?' (line 161) - -
- - -

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 161) - -
- - -
    -
  • access: protected
  • -
- - - - - -
- -
- -
- - mixed - $_searchUrl - (line 168) - -
- - -
    -
  • access: protected
  • -
- - - - - -
- -
- -
- - mixed - $_threadsUrl - (line 168) - -
- - -
    -
  • access: protected
  • -
- - - - - -
- -
- -
- - mixed - $_updateUrl - (line 168) - -
- - -
    -
  • access: protected
  • -
- - - - - -
- -
- -
- - boolean - $_urlsInited - = false (line 175) - -
- - -

Keep track of whether our URLs have been constructed

-
    -
  • access: protected
  • -
- - - - - -
- -
-
- - -
-
Methods
- -
- - -
- -
- static escape (line 192) -
- - -

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 207) -
- - -

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 221) -
- - -

Convenience function for creating phrase syntax from a value

-
    -
  • access: public
  • -
- -
- static string - - phrase - - (string $value) -
- -
    -
  • - string - $value
  • -
- - -
- -
- -
- add (line 667) -
- - -

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: Apache_Solr_HttpTransportException If an error occurs during the service call
  • -
  • access: public
  • -
- -
- Apache_Solr_Response - - add - - (string $rawPost) -
- -
    -
  • - string - $rawPost
  • -
- - -
- -
- -
- addDocument (line 684) -
- - -

Add a Solr Document to the index

-
    -
  • throws: Apache_Solr_HttpTransportException 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], [integer $commitWithin = 0]) -
- -
    -
  • - Apache_Solr_Document - $document
  • -
  • - boolean - $allowDups
  • -
  • - boolean - $overwritePending
  • -
  • - boolean - $overwriteCommitted
  • -
  • - integer - $commitWithin: The number of milliseconds that a document must be committed within, see @{link http://wiki.apache.org/solr/UpdateXmlMessages#The_Update_Schema} for details. If left empty this property will not be set in the request.
  • -
- - -
- -
- -
- addDocuments (line 712) -
- - -

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

-
    -
  • throws: Apache_Solr_HttpTransportException 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], [integer $commitWithin = 0]) -
- -
    -
  • - array - $documents: Should be an array of Apache_Solr_Document instances
  • -
  • - boolean - $allowDups
  • -
  • - boolean - $overwritePending
  • -
  • - boolean - $overwriteCommitted
  • -
  • - integer - $commitWithin: The number of milliseconds that a document must be committed within, see @{link http://wiki.apache.org/solr/UpdateXmlMessages#The_Update_Schema} for details. If left empty this property will not be set in the request.
  • -
- - -
- -
- -
- commit (line 821) -
- - -

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

-
    -
  • throws: Apache_Solr_HttpTransportException If an error occurs during the service call
  • -
  • access: public
  • -
- -
- Apache_Solr_Response - - commit - - ([boolean $expungeDeletes = false], [boolean $waitFlush = true], [boolean $waitSearcher = true], [float $timeout = 3600]) -
- -
    -
  • - boolean - $expungeDeletes: Defaults to false, merge segments with deletes away
  • -
  • - boolean - $waitFlush: Defaults to true, block until index changes are flushed to disk
  • -
  • - boolean - $waitSearcher: Defaults to true, block until a new searcher is opened and registered as the main query searcher, making the changes visible
  • -
  • - 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 842) -
- - -

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: Apache_Solr_HttpTransportException If an error occurs during the service call
  • -
  • access: public
  • -
- -
- Apache_Solr_Response - - delete - - (string $rawPost, [float $timeout = 3600]) -
- -
    -
  • - string - $rawPost: Expected to be utf-8 encoded xml document
  • -
  • - float - $timeout: Maximum expected duration of the delete operation on the server (otherwise, will throw a communication exception)
  • -
- - -
- -
- -
- deleteById (line 858) -
- - -

Create a delete document based on document ID

-
    -
  • throws: Apache_Solr_HttpTransportException If an error occurs during the service call
  • -
  • access: public
  • -
- -
- Apache_Solr_Response - - deleteById - - (string $id, [boolean $fromPending = true], [boolean $fromCommitted = true], [float $timeout = 3600]) -
- -
    -
  • - string - $id: Expected to be utf-8 encoded
  • -
  • - boolean - $fromPending
  • -
  • - boolean - $fromCommitted
  • -
  • - float - $timeout: Maximum expected duration of the delete operation on the server (otherwise, will throw a communication exception)
  • -
- - -
- -
- -
- deleteByMultipleIds (line 882) -
- - -

Create and post a delete document based on multiple document IDs.

-
    -
  • throws: Apache_Solr_HttpTransportException If an error occurs during the service call
  • -
  • access: public
  • -
- -
- Apache_Solr_Response - - deleteByMultipleIds - - (array $ids, [boolean $fromPending = true], [boolean $fromCommitted = true], [float $timeout = 3600]) -
- -
    -
  • - array - $ids: Expected to be utf-8 encoded strings
  • -
  • - boolean - $fromPending
  • -
  • - boolean - $fromCommitted
  • -
  • - float - $timeout: Maximum expected duration of the delete operation on the server (otherwise, will throw a communication exception)
  • -
- - -
- -
- -
- deleteByQuery (line 913) -
- - -

Create a delete document based on a query and submit it

-
    -
  • throws: Apache_Solr_HttpTransportException If an error occurs during the service call
  • -
  • access: public
  • -
- -
- Apache_Solr_Response - - deleteByQuery - - (string $rawQuery, [boolean $fromPending = true], [boolean $fromCommitted = true], [float $timeout = 3600]) -
- -
    -
  • - string - $rawQuery: Expected to be utf-8 encoded
  • -
  • - boolean - $fromPending
  • -
  • - boolean - $fromCommitted
  • -
  • - float - $timeout: Maximum expected duration of the delete operation on the server (otherwise, will throw a communication exception)
  • -
- - -
- -
- -
- extract (line 944) -
- - -

Use Solr Cell to extract document contents. See http://wiki.apache.org/solr/ExtractingRequestHandler for information on how to use Solr Cell and what parameters are available.

-

NOTE: when passing an Apache_Solr_Document instance, field names and boosts will automatically be prepended by "literal." and "boost." as appropriate. Any keys from the $params array will NOT be treated this way. Any mappings from the document will overwrite key / value pairs in the params array if they have the same name (e.g. you pass a "literal.id" key and value in your $params array but you also pass in a document isntance with an "id" field" - the document's value(s) will take precedence).

-
    -
  • throws: Apache_Solr_InvalidArgumentException if $file, $params, or $document are invalid.
  • -
  • access: public
  • -
- -
- Apache_Solr_Response - - extract - - (string $file, [array $params = array()], [Apache_Solr_Document $document = null], [string $mimetype = 'application/octet-stream']) -
- -
    -
  • - string - $file: Path to file to extract data from
  • -
  • - array - $params: optional array of key value pairs that will be sent with the post (see Solr Cell documentation)
  • -
  • - Apache_Solr_Document - $document: optional document that will be used to generate post parameters (literal.* and boost.* params)
  • -
  • - string - $mimetype: optional mimetype specification (for the file being extracted)
  • -
- - -
- -
- -
- extractFromString (line 1005) -
- - -

Use Solr Cell to extract document contents. See http://wiki.apache.org/solr/ExtractingRequestHandler for information on how to use Solr Cell and what parameters are available.

-

NOTE: when passing an Apache_Solr_Document instance, field names and boosts will automatically be prepended by "literal." and "boost." as appropriate. Any keys from the $params array will NOT be treated this way. Any mappings from the document will overwrite key / value pairs in the params array if they have the same name (e.g. you pass a "literal.id" key and value in your $params array but you also pass in a document isntance with an "id" field" - the document's value(s) will take precedence).

-
    -
  • todo: Should be using multipart/form-data to post parameter values, but I could not get my implementation to work. Needs revisisted.
  • -
  • throws: Apache_Solr_InvalidArgumentException if $file, $params, or $document are invalid.
  • -
  • access: public
  • -
- -
- Apache_Solr_Response - - extractFromString - - (string $data, [array $params = array()], [Apache_Solr_Document $document = null], [string $mimetype = 'application/octet-stream']) -
- -
    -
  • - string - $data: Data that will be passed to Solr Cell
  • -
  • - array - $params: optional array of key value pairs that will be sent with the post (see Solr Cell documentation)
  • -
  • - Apache_Solr_Document - $document: optional document that will be used to generate post parameters (literal.* and boost.* params)
  • -
  • - string - $mimetype: optional mimetype specification (for the file being extracted)
  • -
- - -
- -
- -
- extractFromUrl (line 1068) -
- - -

Use Solr Cell to extract document contents. See http://wiki.apache.org/solr/ExtractingRequestHandler for information on how to use Solr Cell and what parameters are available.

-

NOTE: when passing an Apache_Solr_Document instance, field names and boosts will automatically be prepended by "literal." and "boost." as appropriate. Any keys from the $params array will NOT be treated this way. Any mappings from the document will overwrite key / value pairs in the params array if they have the same name (e.g. you pass a "literal.id" key and value in your $params array but you also pass in a document isntance with an "id" field" - the document's value(s) will take precedence).

-
    -
  • throws: Apache_Solr_InvalidArgumentException if $url, $params, or $document are invalid.
  • -
  • access: public
  • -
- -
- Apache_Solr_Response - - extractFromUrl - - (string $url, [array $params = array()], [Apache_Solr_Document $document = null], [string $mimetype = 'application/octet-stream']) -
- -
    -
  • - string - $url: URL
  • -
  • - array - $params: optional array of key value pairs that will be sent with the post (see Solr Cell documentation)
  • -
  • - Apache_Solr_Document - $document: optional document that will be used to generate post parameters (literal.* and boost.* params)
  • -
  • - string - $mimetype: optional mimetype specification (for the file being extracted)
  • -
- - -
- -
- -
- getCollapseSingleValueArrays (line 533) -
- - -

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

-
    -
  • access: public
  • -
- -
- boolean - - getCollapseSingleValueArrays - - () -
- - - -
- -
- -
- getCreateDocuments (line 513) -
- - -

Get the current state of teh create documents flag.

-
    -
  • access: public
  • -
- -
- boolean - - getCreateDocuments - - () -
- - - -
- -
- -
- getDefaultTimeout (line 546) -
- - -

Get the current default timeout setting (initially the default_socket_timeout ini setting) in seconds

-
    -
  • deprecated: Use the getDefaultTimeout method on the HTTP transport implementation
  • -
  • access: public
  • -
- -
- float - - getDefaultTimeout - - () -
- - - -
- -
- -
- getHost (line 375) -
- - -

Returns the set host

-
    -
  • access: public
  • -
- -
- string - - getHost - - () -
- - - -
- -
- -
- getHttpTransport (line 474) -
- - -

Get the current configured HTTP Transport

-
    -
  • access: public
  • -
- -
- HttpTransportInterface - - getHttpTransport - - () -
- - - -
- -
- -
- getNamedListTreatment (line 592) -
- - -

Get the current setting for named list treatment.

-
    -
  • access: public
  • -
- -
- string - - getNamedListTreatment - - () -
- - - -
- -
- -
- getPath (line 447) -
- - -

Get the set path.

-
    -
  • access: public
  • -
- -
- string - - getPath - - () -
- - - -
- -
- -
- getPort (line 410) -
- - -

Get the set port

-
    -
  • access: public
  • -
- -
- integer - - getPort - - () -
- - - -
- -
- -
- Constructor __construct (line 235) -
- - -

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/'], [Apache_Solr_HttpTransport_Interface $httpTransport = false]) -
- - - - -
- -
- -
- optimize (line 1117) -
- - -

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

-
    -
  • throws: Apache_Solr_HttpTransportException 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 626) -
- - -

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 or HTTP error status 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 1140) -
- - -

Simple Search interface

-
    -
  • throws: Apache_Solr_InvalidArgumentException If an invalid HTTP method is used
  • -
  • throws: Apache_Solr_HttpTransportException 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 $method = self::METHOD_GET]) -
- -
    -
  • - 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)
  • -
  • - string - $method: The HTTP method (Apache_Solr_Service::METHOD_GET or Apache_Solr_Service::METHOD::POST)
  • -
- - -
- -
- -
- setCollapseSingleValueArrays (line 523) -
- - -

Set the collapse single value arrays flag.

-
    -
  • access: public
  • -
- -
- void - - setCollapseSingleValueArrays - - (boolean $collapseSingleValueArrays) -
- -
    -
  • - boolean - $collapseSingleValueArrays
  • -
- - -
- -
- -
- setCreateDocuments (line 503) -
- - -

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 - - (boolean $createDocuments) -
- -
    -
  • - boolean - $createDocuments
  • -
- - -
- -
- -
- setDefaultTimeout (line 558) -
- - -

Set the default timeout for all calls that aren't passed a specific timeout

-
    -
  • deprecated: Use the setDefaultTimeout method on the HTTP transport implementation
  • -
  • access: public
  • -
- -
- void - - setDefaultTimeout - - (float $timeout) -
- -
    -
  • - float - $timeout: Timeout value in seconds
  • -
- - -
- -
- -
- setHost (line 387) -
- - -

Set the host used. If empty will fallback to constants

-
    -
  • throws: Apache_Solr_InvalidArgumentException If the host parameter is empty
  • -
  • access: public
  • -
- -
- void - - setHost - - (string $host) -
- -
    -
  • - string - $host
  • -
- - -
- -
- -
- setHttpTransport (line 492) -
- - -

Set the HTTP Transport implemenation that will be used for all HTTP requests

-
    -
  • access: public
  • -
- -
- void - - setHttpTransport - - (Apache_Solr_HttpTransport_Interface $httpTransport) -
- - - - -
- -
- -
- setNamedListTreatment (line 570) -
- - -

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

-
    -
  • throws: Apache_Solr_InvalidArgumentException If invalid option is set
  • -
  • access: public
  • -
- -
- void - - setNamedListTreatment - - (string $namedListTreatment) -
- -
    -
  • - string - $namedListTreatment
  • -
- - -
- -
- -
- setPath (line 457) -
- - -

Set the path used. If empty will fallback to constants

-
    -
  • access: public
  • -
- -
- void - - setPath - - (string $path) -
- -
    -
  • - string - $path
  • -
- - -
- -
- -
- setPort (line 422) -
- - -

Set the port used. If empty will fallback to constants

-
    -
  • throws: Apache_Solr_InvalidArgumentException If the port parameter is empty
  • -
  • access: public
  • -
- -
- void - - setPort - - (integer $port) -
- -
    -
  • - integer - $port
  • -
- - -
- -
- -
- setQueryDelimiter (line 603) -
- - -

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

-

Defaulted to '?'

-
    -
  • access: public
  • -
- -
- void - - setQueryDelimiter - - (string $queryDelimiter) -
- -
    -
  • - string - $queryDelimiter
  • -
- - -
- -
- -
- setQueryStringDelimiter (line 614) -
- - -

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

-
    -
  • access: public
  • -
- -
- void - - setQueryStringDelimiter - - (string $queryStringDelimiter) -
- -
    -
  • - string - $queryStringDelimiter
  • -
- - -
- -
- -
- threads (line 653) -
- - -

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

-
    -
  • throws: Apache_Solr_HttpTransportException If an error occurs during the service call
  • -
  • access: public
  • -
- -
- Apache_Solr_Response - - threads - - () -
- - - -
- -
- -
- _constructUrl (line 258) -
- - -

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 741) -
- - -

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) -
- - - - -
- -
- -
- _generateQueryString (line 295) -
- - -
    -
  • access: protected
  • -
- -
- void - - _generateQueryString - - ( $params) -
- -
    -
  • - - $params
  • -
- - -
- -
- -
- _initUrls (line 283) -
- - -

Construct the Full URLs for the three servlets we reference

-
    -
  • access: protected
  • -
- -
- void - - _initUrls - - () -
- - - -
- -
- -
- _sendRawGet (line 329) -
- - -

Central method for making a get operation against this Solr Server

-
    -
  • throws: Apache_Solr_HttpTransportException 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 355) -
- - -

Central method for making a post operation against this Solr Server

-
    -
  • throws: Apache_Solr_HttpTransportException 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
  • -
- - -
- -
- -
- _stripCtrlChars (line 803) -
- - -

Replace control (non-printable) characters from string that are invalid to Solr's XML parser with a space.

-
    -
  • access: protected
  • -
- -
- string - - _stripCtrlChars - - (string $string) -
- -
    -
  • - string - $string
  • -
- - -
- -
-
- - -
-
Class Constants
- -
- -
- -
- - - EXTRACT_SERVLET - = 'update/extract' - (line 122) - -
- - - - -
- -
- -
- - - METHOD_GET - = 'GET' - (line 112) - -
- - -

Search HTTP Methods

- - -
- -
- -
- - - METHOD_POST - = 'POST' - (line 113) - -
- - - - -
- -
- -
- - - NAMED_LIST_FLAT - = 'flat' - (line 106) - -
- - -

NamedList Treatment constants

- - -
- -
- -
- - - NAMED_LIST_MAP - = 'map' - (line 107) - -
- - - - -
- -
- -
- - - PING_SERVLET - = 'admin/ping' - (line 118) - -
- - -

Servlet mappings

- - -
- -
- -
- - - SEARCH_SERVLET - = 'select' - (line 120) - -
- - - - -
- -
- -
- - - SOLR_WRITER - = 'json' - (line 101) - -
- - -

Response writer we'll request - JSON. See http://code.google.com/p/solr-php-client/issues/detail?id=6#c1 for reasoning

- - -
- -
- -
- - - SVN_ID - = '$Id: Service.php 59 2011-02-08 20:38:59Z donovan.jimenez $' - (line 96) - -
- - -

SVN ID meta data for this class

- - -
- -
- -
- - - SVN_REVISION - = '$Revision: 59 $' - (line 91) - -
- - -

SVN Revision meta data for this class

- - -
- -
- -
- - - THREADS_SERVLET - = 'admin/threads' - (line 121) - -
- - - - -
- -
- -
- - - UPDATE_SERVLET - = 'update' - (line 119) - -
- - - - -
- -
-
- -

- Documentation generated on Wed, 04 May 2011 11:01:19 -0400 by phpDocumentor 1.4.3 -

-
- \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_Service_Balancer.html b/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_Service_Balancer.html deleted file mode 100644 index f74c898c..00000000 --- a/SolrPhpClient/phpdocs/Apache/Solr/Apache_Solr_Service_Balancer.html +++ /dev/null @@ -1,1606 +0,0 @@ - - - - - - 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 51) -

- - -

-	
-			
-
- - - -
-
Class Constant Summary
- -
-
-
-  - SVN_ID = '$Id: Balancer.php 54 2011-02-04 16:29:18Z donovan.jimenez $' - -
-
-  - SVN_REVISION = '$Revision: 54 $' - -
-
-
-
- - -
-
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, [float $timeout = 3600]) -
- -
- Apache_Solr_Response - deleteById - (string $id, [boolean $fromPending = true], [boolean $fromCommitted = true], [float $timeout = 3600]) -
- -
- Apache_Solr_Response - deleteByMultipleIds - (array $ids, [boolean $fromPending = true], [boolean $fromCommitted = true], [float $timeout = 3600]) -
- -
- Apache_Solr_Response - deleteByQuery - (string $rawQuery, [boolean $fromPending = true], [boolean $fromCommitted = true], [float $timeout = 3600]) -
- -
- Apache_Solr_Response - extract - (string $file, [array $params = array()], [Apache_Solr_Document $document = null], [string $mimetype = 'application/octet-stream']) -
- -
- Apache_Solr_Response - extractFromString - (string $data, [array $params = array()], [Apache_Solr_Document $document = null], [string $mimetype = 'application/octet-stream']) -
- -
- boolean - getCreateDocuments - () -
- -
- Apache_Solr_Response - optimize - ([boolean $waitFlush = true], [boolean $waitSearcher = true], [float $timeout = 3600]) -
- -
- void - removeReadService - (mixed $service) -
- -
- void - removeWriteService - (mixed $service) -
- -
- Apache_Solr_Response - search - (string $query, [int $offset = 0], [int $limit = 10], [array $params = array()], [string $method = Apache_Solr_Service::METHOD_GET]) -
- -
- void - setCreateDocuments - (boolean $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 77) - -
- - -
    -
  • access: protected
  • -
- - - - - -
- -
- -
- - mixed - $_backoffLimit - = 600 (line 76) - -
- - -
    -
  • access: protected
  • -
- - - - - -
- -
- -
- - mixed - $_createDocuments - = true (line 63) - -
- - -
    -
  • access: protected
  • -
- - - - - -
- -
- -
- - mixed - $_currentReadService - = null (line 68) - -
- - -
    -
  • access: protected
  • -
- - - - - -
- -
- -
- - mixed - $_currentWriteService - = null (line 69) - -
- - -
    -
  • access: protected
  • -
- - - - - -
- -
- -
- - mixed - $_defaultBackoff - = 2.0 (line 78) - -
- - -
    -
  • access: protected
  • -
- - - - - -
- -
- -
- - mixed - $_readableServices - = array() (line 65) - -
- - -
    -
  • access: protected
  • -
- - - - - -
- -
- -
- - mixed - $_readPingTimeout - = 2 (line 71) - -
- - -
    -
  • access: protected
  • -
- - - - - -
- -
- -
- - mixed - $_useBackoff - = false (line 75) - -
- - -
    -
  • access: protected
  • -
- - - - - -
- -
- -
- - mixed - $_writeableServices - = array() (line 66) - -
- - -
    -
  • access: protected
  • -
- - - - - -
- -
- -
- - mixed - $_writePingTimeout - = 4 (line 72) - -
- - -
    -
  • access: protected
  • -
- - - - - -
- -
-
- - -
-
Methods
- -
- - -
- -
- static escape (line 88) -
- - -

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 99) -
- - -

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 110) -
- - -

Convenience function for creating phrase syntax from a value

-
    -
  • access: public
  • -
- -
- static string - - phrase - - (string $value) -
- -
    -
  • - string - $value
  • -
- - -
- -
- -
- Constructor __construct (line 121) -
- - -

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 491) -
- - -

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: Apache_Solr_HttpTransportException If an error occurs during the service call
  • -
  • access: public
  • -
- -
- Apache_Solr_Response - - add - - (string $rawPost) -
- -
    -
  • - string - $rawPost
  • -
- - -
- -
- -
- addDocument (line 526) -
- - -

Add a Solr Document to the index

-
    -
  • throws: Apache_Solr_HttpTransportException 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 561) -
- - -

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

-
    -
  • throws: Apache_Solr_HttpTransportException 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 172) -
- - -

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

-
    -
  • throws: Apache_Solr_InvalidArgumentException If service descriptor is not valid
  • -
  • access: public
  • -
- -
- void - - addReadService - - (mixed $service) -
- -
    -
  • - mixed - $service
  • -
- - -
- -
- -
- addWriteService (line 240) -
- - -

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

-
    -
  • throws: Apache_Solr_InvalidArgumentException If service descriptor is not valid
  • -
  • access: public
  • -
- -
- void - - addWriteService - - (mixed $service) -
- -
    -
  • - mixed - $service
  • -
- - -
- -
- -
- commit (line 595) -
- - -

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

-
    -
  • throws: Apache_Solr_HttpTransportException 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 629) -
- - -

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: Apache_Solr_HttpTransportException If an error occurs during the service call
  • -
  • access: public
  • -
- -
- Apache_Solr_Response - - delete - - (string $rawPost, [float $timeout = 3600]) -
- -
    -
  • - string - $rawPost
  • -
  • - float - $timeout: Maximum expected duration of the delete operation on the server (otherwise, will throw a communication exception)
  • -
- - -
- -
- -
- deleteById (line 664) -
- - -

Create a delete document based on document ID

-
    -
  • throws: Apache_Solr_HttpTransportException If an error occurs during the service call
  • -
  • access: public
  • -
- -
- Apache_Solr_Response - - deleteById - - (string $id, [boolean $fromPending = true], [boolean $fromCommitted = true], [float $timeout = 3600]) -
- -
    -
  • - string - $id
  • -
  • - boolean - $fromPending
  • -
  • - boolean - $fromCommitted
  • -
  • - float - $timeout: Maximum expected duration of the delete operation on the server (otherwise, will throw a communication exception)
  • -
- - -
- -
- -
- deleteByMultipleIds (line 699) -
- - -

Create and post a delete document based on multiple document IDs.

-
    -
  • throws: Apache_Solr_HttpTransportException If an error occurs during the service call
  • -
  • access: public
  • -
- -
- Apache_Solr_Response - - deleteByMultipleIds - - (array $ids, [boolean $fromPending = true], [boolean $fromCommitted = true], [float $timeout = 3600]) -
- -
    -
  • - array - $ids: Expected to be utf-8 encoded strings
  • -
  • - boolean - $fromPending
  • -
  • - boolean - $fromCommitted
  • -
  • - float - $timeout: Maximum expected duration of the delete operation on the server (otherwise, will throw a communication exception)
  • -
- - -
- -
- -
- deleteByQuery (line 734) -
- - -

Create a delete document based on a query and submit it

-
    -
  • throws: Apache_Solr_HttpTransportException If an error occurs during the service call
  • -
  • access: public
  • -
- -
- Apache_Solr_Response - - deleteByQuery - - (string $rawQuery, [boolean $fromPending = true], [boolean $fromCommitted = true], [float $timeout = 3600]) -
- -
    -
  • - string - $rawQuery
  • -
  • - boolean - $fromPending
  • -
  • - boolean - $fromCommitted
  • -
  • - float - $timeout: Maximum expected duration of the delete operation on the server (otherwise, will throw a communication exception)
  • -
- - -
- -
- -
- extract (line 776) -
- - -

Use Solr Cell to extract document contents. See http://wiki.apache.org/solr/ExtractingRequestHandler for information on how to use Solr Cell and what parameters are available.

-

NOTE: when passing an Apache_Solr_Document instance, field names and boosts will automatically be prepended by "literal." and "boost." as appropriate. Any keys from the $params array will NOT be treated this way. Any mappings from the document will overwrite key / value pairs in the params array if they have the same name (e.g. you pass a "literal.id" key and value in your $params array but you also pass in a document isntance with an "id" field" - the document's value(s) will take precedence).

-
    -
  • throws: Apache_Solr_InvalidArgumentException if $file, $params, or $document are invalid.
  • -
  • access: public
  • -
- -
- Apache_Solr_Response - - extract - - (string $file, [array $params = array()], [Apache_Solr_Document $document = null], [string $mimetype = 'application/octet-stream']) -
- -
    -
  • - string - $file: Path to file to extract data from
  • -
  • - array - $params: optional array of key value pairs that will be sent with the post (see Solr Cell documentation)
  • -
  • - Apache_Solr_Document - $document: optional document that will be used to generate post parameters (literal.* and boost.* params)
  • -
  • - string - $mimetype: optional mimetype specification (for the file being extracted)
  • -
- - -
- -
- -
- extractFromString (line 820) -
- - -

Use Solr Cell to extract document contents. See http://wiki.apache.org/solr/ExtractingRequestHandler for information on how to use Solr Cell and what parameters are available.

-

NOTE: when passing an Apache_Solr_Document instance, field names and boosts will automatically be prepended by "literal." and "boost." as appropriate. Any keys from the $params array will NOT be treated this way. Any mappings from the document will overwrite key / value pairs in the params array if they have the same name (e.g. you pass a "literal.id" key and value in your $params array but you also pass in a document isntance with an "id" field" - the document's value(s) will take precedence).

-
    -
  • todo: Should be using multipart/form-data to post parameter values, but I could not get my implementation to work. Needs revisisted.
  • -
  • throws: Apache_Solr_InvalidArgumentException if $file, $params, or $document are invalid.
  • -
  • access: public
  • -
- -
- Apache_Solr_Response - - extractFromString - - (string $data, [array $params = array()], [Apache_Solr_Document $document = null], [string $mimetype = 'application/octet-stream']) -
- -
    -
  • - string - $data: Data that will be passed to Solr Cell
  • -
  • - array - $params: optional array of key value pairs that will be sent with the post (see Solr Cell documentation)
  • -
  • - Apache_Solr_Document - $document: optional document that will be used to generate post parameters (literal.* and boost.* params)
  • -
  • - string - $mimetype: optional mimetype specification (for the file being extracted)
  • -
- - -
- -
- -
- getCreateDocuments (line 477) -
- - -

Get the current state of teh create documents flag.

-
    -
  • access: public
  • -
- -
- boolean - - getCreateDocuments - - () -
- - - -
- -
- -
- optimize (line 855) -
- - -

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

-
    -
  • throws: Apache_Solr_HttpTransportException 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 optimize operation on the server (otherwise, will throw a communication exception)
  • -
- - -
- -
- -
- removeReadService (line 202) -
- - -

Removes a service instance or descriptor from the available services

-
    -
  • throws: Apache_Solr_InvalidArgumentException If service descriptor is not valid
  • -
  • access: public
  • -
- -
- void - - removeReadService - - (mixed $service) -
- -
    -
  • - mixed - $service
  • -
- - -
- -
- -
- removeWriteService (line 270) -
- - -

Removes a service instance or descriptor from the available services

-
    -
  • throws: Apache_Solr_InvalidArgumentException If service descriptor is not valid
  • -
  • access: public
  • -
- -
- void - - removeWriteService - - (mixed $service) -
- -
    -
  • - mixed - $service
  • -
- - -
- -
- -
- search (line 891) -
- - -

Simple Search interface

-
    -
  • throws: Apache_Solr_HttpTransportException 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 $method = Apache_Solr_Service::METHOD_GET]) -
- -
    -
  • - 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
  • -
  • - string - $method: The HTTP method (Apache_Solr_Service::METHOD_GET or Apache_Solr_Service::METHOD::POST)
  • -
- - -
- -
- -
- setCreateDocuments (line 460) -
- - -

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 - - (boolean $createDocuments) -
- -
    -
  • - boolean - $createDocuments
  • -
- - -
- -
- -
- setReadPingTimeout (line 136) -
- - -
    -
  • access: public
  • -
- -
- void - - setReadPingTimeout - - ( $timeout) -
- -
    -
  • - - $timeout
  • -
- - -
- -
- -
- setUseBackoff (line 146) -
- - -
    -
  • access: public
  • -
- -
- void - - setUseBackoff - - ( $enable) -
- -
    -
  • - - $enable
  • -
- - -
- -
- -
- setWritePingTimeout (line 141) -
- - -
    -
  • access: public
  • -
- -
- void - - setWritePingTimeout - - ( $timeout) -
- -
    -
  • - - $timeout
  • -
- - -
- -
- -
- _getServiceId (line 159) -
- - -

Generates a service ID

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

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

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

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

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

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: Apache_Solr_NoServiceAvailableException If there are no write services that meet requirements
  • -
  • access: protected
  • -
- -
- Apache_Solr_Service - - _selectWriteServiceSafe - - ([ $forceSelect = false]) -
- -
    -
  • - - $forceSelect
  • -
- - -
- -
-
- - -
-
Class Constants
- -
- -
- -
- - - SVN_ID - = '$Id: Balancer.php 54 2011-02-04 16:29:18Z donovan.jimenez $' - (line 61) - -
- - -

SVN ID meta data for this class

- - -
- -
- -
- - - SVN_REVISION - = '$Revision: 54 $' - (line 56) - -
- - -

SVN Revision meta data for this class

- - -
- -
-
- -

- Documentation generated on Wed, 04 May 2011 11:01:10 -0400 by phpDocumentor 1.4.3 -

-
- \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/Apache/Solr/_Document.php.html b/SolrPhpClient/phpdocs/Apache/Solr/_Document.php.html deleted file mode 100644 index 30b56248..00000000 --- a/SolrPhpClient/phpdocs/Apache/Solr/_Document.php.html +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - Docs for page Document.php - - - - -
-

/Document.php

- - -
-
Description
- -
- -

Copyright (c) 2007-2011, Servigistics, Inc.

-

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution.
  • Neither the name of Servigistics, Inc. nor the names of - its contributors may be used to endorse or promote products derived from - this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

- - -
-
- - -
-
Classes
- -
- - - - - - - - - -
ClassDescription
- Apache_Solr_Document - - Holds Key / Value pairs that represent a Solr Document along with any associated boost values. Field values can be accessed by direct dereferencing such as: -
-
-
- - - - - -

- Documentation generated on Wed, 04 May 2011 11:01:13 -0400 by phpDocumentor 1.4.3 -

-
- \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/Apache/Solr/_Exception.php.html b/SolrPhpClient/phpdocs/Apache/Solr/_Exception.php.html deleted file mode 100644 index c6cef5e8..00000000 --- a/SolrPhpClient/phpdocs/Apache/Solr/_Exception.php.html +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - Docs for page Exception.php - - - - -
-

/Exception.php

- - -
-
Description
- -
- - - -
-
- - -
-
Classes
- -
- - - - - - - - - -
ClassDescription
- Apache_Solr_Exception - - Copyright (c) 2007-2011, Servigistics, Inc. -
-
-
- - - - - -

- Documentation generated on Wed, 04 May 2011 11:01:13 -0400 by phpDocumentor 1.4.3 -

-
- \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/Apache/Solr/_HttpTransport---Abstract.php.html b/SolrPhpClient/phpdocs/Apache/Solr/_HttpTransport---Abstract.php.html deleted file mode 100644 index ae504ef7..00000000 --- a/SolrPhpClient/phpdocs/Apache/Solr/_HttpTransport---Abstract.php.html +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - Docs for page Abstract.php - - - - -
-

/HttpTransport/Abstract.php

- - -
-
Description
- -
- -

Copyright (c) 2007-2011, Servigistics, Inc.

-

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution.
  • Neither the name of Servigistics, Inc. nor the names of - its contributors may be used to endorse or promote products derived from - this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

- - -
-
- - -
-
Classes
- -
- - - - - - - - - -
ClassDescription
- Apache_Solr_HttpTransport_Abstract - - Convenience class that implements the transport implementation. Can be extended by -
-
-
- - - - - -

- Documentation generated on Wed, 04 May 2011 11:01:08 -0400 by phpDocumentor 1.4.3 -

-
- \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/Apache/Solr/_HttpTransport---Curl.php.html b/SolrPhpClient/phpdocs/Apache/Solr/_HttpTransport---Curl.php.html deleted file mode 100644 index 49662ace..00000000 --- a/SolrPhpClient/phpdocs/Apache/Solr/_HttpTransport---Curl.php.html +++ /dev/null @@ -1,101 +0,0 @@ - - - - - - Docs for page Curl.php - - - - -
-

/HttpTransport/Curl.php

- - -
-
Description
- -
- -

Copyright (c) 2007-2011, Servigistics, Inc.

-

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution.
  • Neither the name of Servigistics, Inc. nor the names of - its contributors may be used to endorse or promote products derived from - this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

- - -
-
- - -
-
Classes
- -
- - - - - - - - - -
ClassDescription
- Apache_Solr_HttpTransport_Curl - - A Curl based HTTP transport. Uses a single curl session for all requests. -
-
-
- - -
-
Includes
- -
- -
- -
- - require_once - (dirname(__FILE__).'/Abstract.php') - (line 40) - -
- - - -
-
-
- - - - -

- Documentation generated on Wed, 04 May 2011 11:01:11 -0400 by phpDocumentor 1.4.3 -

-
- \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/Apache/Solr/_HttpTransport---CurlNoReuse.php.html b/SolrPhpClient/phpdocs/Apache/Solr/_HttpTransport---CurlNoReuse.php.html deleted file mode 100644 index 1c2eab39..00000000 --- a/SolrPhpClient/phpdocs/Apache/Solr/_HttpTransport---CurlNoReuse.php.html +++ /dev/null @@ -1,101 +0,0 @@ - - - - - - Docs for page CurlNoReuse.php - - - - -
-

/HttpTransport/CurlNoReuse.php

- - -
-
Description
- -
- -

Copyright (c) 2007-2011, Servigistics, Inc.

-

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution.
  • Neither the name of Servigistics, Inc. nor the names of - its contributors may be used to endorse or promote products derived from - this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

- - -
-
- - -
-
Classes
- -
- - - - - - - - - -
ClassDescription
- Apache_Solr_HttpTransport_CurlNoReuse - - An alternative Curl HTTP transport that opens and closes a curl session for every request. This isn't the recommended way to use curl, but some version of PHP have memory issues. -
-
-
- - -
-
Includes
- -
- -
- -
- - require_once - (dirname(__FILE__).'/Abstract.php') - (line 40) - -
- - - -
-
-
- - - - -

- Documentation generated on Wed, 04 May 2011 11:01:12 -0400 by phpDocumentor 1.4.3 -

-
- \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/Apache/Solr/_HttpTransport---FileGetContents.php.html b/SolrPhpClient/phpdocs/Apache/Solr/_HttpTransport---FileGetContents.php.html deleted file mode 100644 index 02984e62..00000000 --- a/SolrPhpClient/phpdocs/Apache/Solr/_HttpTransport---FileGetContents.php.html +++ /dev/null @@ -1,101 +0,0 @@ - - - - - - Docs for page FileGetContents.php - - - - -
-

/HttpTransport/FileGetContents.php

- - -
-
Description
- -
- -

Copyright (c) 2007-2011, Servigistics, Inc.

-

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution.
  • Neither the name of Servigistics, Inc. nor the names of - its contributors may be used to endorse or promote products derived from - this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

- - -
-
- - -
-
Classes
- -
- - - - - - - - - -
ClassDescription
- Apache_Solr_HttpTransport_FileGetContents - - HTTP Transport implemenation that uses the builtin http URL wrappers and file_get_contents -
-
-
- - -
-
Includes
- -
- -
- -
- - require_once - (dirname(__FILE__).'/Abstract.php') - (line 40) - -
- - - -
-
-
- - - - -

- Documentation generated on Wed, 04 May 2011 11:01:13 -0400 by phpDocumentor 1.4.3 -

-
- \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/Apache/Solr/_HttpTransport---Interface.php.html b/SolrPhpClient/phpdocs/Apache/Solr/_HttpTransport---Interface.php.html deleted file mode 100644 index a4d9965a..00000000 --- a/SolrPhpClient/phpdocs/Apache/Solr/_HttpTransport---Interface.php.html +++ /dev/null @@ -1,101 +0,0 @@ - - - - - - Docs for page Interface.php - - - - -
-

/HttpTransport/Interface.php

- - -
-
Description
- -
- -

Copyright (c) 2007-2011, Servigistics, Inc.

-

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution.
  • Neither the name of Servigistics, Inc. nor the names of - its contributors may be used to endorse or promote products derived from - this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

- - -
-
- - -
-
Classes
- -
- - - - - - - - - -
ClassDescription
- Apache_Solr_HttpTransport_Interface - - Interface that all Transport (HTTP Requester) implementations must implement. These -
-
-
- - -
-
Includes
- -
- -
- -
- - require_once - (dirname(__FILE__).'/Response.php') - (line 40) - -
- - - -
-
-
- - - - -

- Documentation generated on Wed, 04 May 2011 11:01:14 -0400 by phpDocumentor 1.4.3 -

-
- \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/Apache/Solr/_HttpTransport---Response.php.html b/SolrPhpClient/phpdocs/Apache/Solr/_HttpTransport---Response.php.html deleted file mode 100644 index f12a5804..00000000 --- a/SolrPhpClient/phpdocs/Apache/Solr/_HttpTransport---Response.php.html +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - Docs for page Response.php - - - - -
-

/HttpTransport/Response.php

- - -
-
Description
- -
- -

Copyright (c) 2007-2011, Servigistics, Inc.

-

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution.
  • Neither the name of Servigistics, Inc. nor the names of - its contributors may be used to endorse or promote products derived from - this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

- - -
-
- - -
-
Classes
- -
- - - - - - - - - -
ClassDescription
- Apache_Solr_HttpTransport_Response - - Represents the required pieces of an HTTP response provided by HTTP transport -
-
-
- - - - - -

- Documentation generated on Wed, 04 May 2011 11:01:15 -0400 by phpDocumentor 1.4.3 -

-
- \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/Apache/Solr/_HttpTransportException.php.html b/SolrPhpClient/phpdocs/Apache/Solr/_HttpTransportException.php.html deleted file mode 100644 index 03f7d50f..00000000 --- a/SolrPhpClient/phpdocs/Apache/Solr/_HttpTransportException.php.html +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - Docs for page HttpTransportException.php - - - - -
-

/HttpTransportException.php

- - -
-
Description
- -
- - - -
-
- - -
-
Classes
- -
- - - - - - - - - -
ClassDescription
- Apache_Solr_HttpTransportException - - Copyright (c) 2007-2011, Servigistics, Inc. -
-
-
- - - - - -

- Documentation generated on Wed, 04 May 2011 11:01:14 -0400 by phpDocumentor 1.4.3 -

-
- \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/Apache/Solr/_InvalidArgumentException.php.html b/SolrPhpClient/phpdocs/Apache/Solr/_InvalidArgumentException.php.html deleted file mode 100644 index fdb0c671..00000000 --- a/SolrPhpClient/phpdocs/Apache/Solr/_InvalidArgumentException.php.html +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - Docs for page InvalidArgumentException.php - - - - -
-

/InvalidArgumentException.php

- - -
-
Description
- -
- - - -
-
- - -
-
Classes
- -
- - - - - - - - - -
ClassDescription
- Apache_Solr_InvalidArgumentException - - Copyright (c) 2007-2011, Servigistics, Inc. -
-
-
- - - - - -

- Documentation generated on Wed, 04 May 2011 11:01:15 -0400 by phpDocumentor 1.4.3 -

-
- \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/Apache/Solr/_NoServiceAvailableException.php.html b/SolrPhpClient/phpdocs/Apache/Solr/_NoServiceAvailableException.php.html deleted file mode 100644 index 00d4b4e0..00000000 --- a/SolrPhpClient/phpdocs/Apache/Solr/_NoServiceAvailableException.php.html +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - Docs for page NoServiceAvailableException.php - - - - -
-

/NoServiceAvailableException.php

- - -
-
Description
- -
- - - -
-
- - -
-
Classes
- -
- - - - - - - - - -
ClassDescription
- Apache_Solr_NoServiceAvailableException - - Copyright (c) 2007-2011, Servigistics, Inc. -
-
-
- - - - - -

- Documentation generated on Wed, 04 May 2011 11:01:15 -0400 by phpDocumentor 1.4.3 -

-
- \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/Apache/Solr/_ParserException.php.html b/SolrPhpClient/phpdocs/Apache/Solr/_ParserException.php.html deleted file mode 100644 index 8a69171e..00000000 --- a/SolrPhpClient/phpdocs/Apache/Solr/_ParserException.php.html +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - Docs for page ParserException.php - - - - -
-

/ParserException.php

- - -
-
Description
- -
- - - -
-
- - -
-
Classes
- -
- - - - - - - - - -
ClassDescription
- Apache_Solr_ParserException - - Copyright (c) 2007-2011, Servigistics, Inc. -
-
-
- - - - - -

- Documentation generated on Wed, 04 May 2011 11:01:15 -0400 by phpDocumentor 1.4.3 -

-
- \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/Apache/Solr/_Response.php.html b/SolrPhpClient/phpdocs/Apache/Solr/_Response.php.html deleted file mode 100644 index 3093bbac..00000000 --- a/SolrPhpClient/phpdocs/Apache/Solr/_Response.php.html +++ /dev/null @@ -1,101 +0,0 @@ - - - - - - Docs for page Response.php - - - - -
-

/Response.php

- - -
-
Description
- -
- -

Copyright (c) 2007-2011, Servigistics, Inc.

-

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution.
  • Neither the name of Servigistics, Inc. nor the names of - its contributors may be used to endorse or promote products derived from - this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

- - -
-
- - -
-
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. -
-
-
- - -
-
Includes
- -
- -
- -
- - require_once - (dirname(__FILE__).'/ParserException.php') - (line 39) - -
- - - -
-
-
- - - - -

- Documentation generated on Wed, 04 May 2011 11:01:15 -0400 by phpDocumentor 1.4.3 -

-
- \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/Apache/Solr/_Service---Balancer.php.html b/SolrPhpClient/phpdocs/Apache/Solr/_Service---Balancer.php.html deleted file mode 100644 index 9aaffbfb..00000000 --- a/SolrPhpClient/phpdocs/Apache/Solr/_Service---Balancer.php.html +++ /dev/null @@ -1,115 +0,0 @@ - - - - - - Docs for page Balancer.php - - - - -
-

/Service/Balancer.php

- - -
-
Description
- -
- -

Copyright (c) 2007-2011, Servigistics, Inc.

-

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution.
  • Neither the name of Servigistics, Inc. nor the names of - its contributors may be used to endorse or promote products derived from - this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

- - -
-
- - -
-
Classes
- -
- - - - - - - - - -
ClassDescription
- Apache_Solr_Service_Balancer - - Reference Implementation for using multiple Solr services in a distribution. Functionality -
-
-
- - -
-
Includes
- -
- -
- -
- - require_once - (dirname(dirname(__FILE__)).'/Service.php') - (line 41) - -
- - - -
- -
- -
- - require_once - (dirname(dirname(__FILE__)).'/NoServiceAvailableException.php') - (line 43) - -
- - - -
-
-
- - - - -

- Documentation generated on Wed, 04 May 2011 11:01:08 -0400 by phpDocumentor 1.4.3 -

-
- \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/Apache/Solr/_Service.php.html b/SolrPhpClient/phpdocs/Apache/Solr/_Service.php.html deleted file mode 100644 index 39725a04..00000000 --- a/SolrPhpClient/phpdocs/Apache/Solr/_Service.php.html +++ /dev/null @@ -1,171 +0,0 @@ - - - - - - Docs for page Service.php - - - - -
-

/Service.php

- - -
-
Description
- -
- -

Copyright (c) 2007-2011, Servigistics, Inc.

-

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution.
  • Neither the name of Servigistics, Inc. nor the names of - its contributors may be used to endorse or promote products derived from - this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

- - -
-
- - -
-
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 - (dirname(__FILE__).'/HttpTransportException.php') - (line 42) - -
- - - -
- -
- -
- - require_once - (dirname(__FILE__).'/Exception.php') - (line 41) - -
- - - -
- -
- -
- - require_once - (dirname(__FILE__).'/InvalidArgumentException.php') - (line 43) - -
- - - -
- -
- -
- - require_once - (dirname(__FILE__).'/Document.php') - (line 45) - -
- - - -
- -
- -
- - require_once - (dirname(__FILE__).'/HttpTransport/Interface.php') - (line 48) - -
- - - -
- -
- -
- - require_once - (dirname(__FILE__).'/Response.php') - (line 46) - -
- - - -
-
-
- - - - -

- Documentation generated on Wed, 04 May 2011 11:01:16 -0400 by phpDocumentor 1.4.3 -

-
- \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_Document.php.html b/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_Document.php.html deleted file mode 100644 index fac94127..00000000 --- a/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_Document.php.html +++ /dev/null @@ -1,387 +0,0 @@ - - - - - - File Source for Document.php - - - - -

Source for file Document.php

-

Documentation is available at Document.php

-
-
  1. <?php
  2. -
  3. /**
  4. -
  5.  * Copyright (c) 2007-2011, Servigistics, Inc.
  6. -
  7.  * All rights reserved.
  8. -
  9.  *
  10. -
  11.  * Redistribution and use in source and binary forms, with or without
  12. -
  13.  * modification, are permitted provided that the following conditions are met:
  14. -
  15.  *
  16. -
  17.  *  - Redistributions of source code must retain the above copyright notice,
  18. -
  19.  *    this list of conditions and the following disclaimer.
  20. -
  21.  *  - Redistributions in binary form must reproduce the above copyright
  22. -
  23.  *    notice, this list of conditions and the following disclaimer in the
  24. -
  25.  *    documentation and/or other materials provided with the distribution.
  26. -
  27.  *  - Neither the name of Servigistics, Inc. nor the names of
  28. -
  29.  *    its contributors may be used to endorse or promote products derived from
  30. -
  31.  *    this software without specific prior written permission.
  32. -
  33.  *
  34. -
  35.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  36. -
  37.  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  38. -
  39.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  40. -
  41.  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  42. -
  43.  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  44. -
  45.  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  46. -
  47.  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  48. -
  49.  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  50. -
  51.  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  52. -
  53.  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  54. -
  55.  * POSSIBILITY OF SUCH DAMAGE.
  56. -
  57.  *
  58. -
  59.  * @copyright Copyright 2007-2011 Servigistics, Inc. (http://servigistics.com)
  60. -
  61.  * @license http://solr-php-client.googlecode.com/svn/trunk/COPYING New BSD
  62. -
  63.  * @version $Id: Document.php 54 2011-02-04 16:29:18Z donovan.jimenez $
  64. -
  65.  *
  66. -
  67.  * @package Apache
  68. -
  69.  * @subpackage Solr
  70. -
  71.  * @author Donovan Jimenez <djimenez@conduit-it.com>
  72. -
  73.  */
  74. -
  75.  
  76. -
  77. /**
  78. -
  79.  * Holds Key / Value pairs that represent a Solr Document along with any associated boost
  80. -
  81.  * values. Field values can be accessed by direct dereferencing such as:
  82. -
  83.  * <code>
  84. -
  85.  * ...
  86. -
  87.  * $document->title = 'Something';
  88. -
  89.  * echo $document->title;
  90. -
  91.  * ...
  92. -
  93.  * </code>
  94. -
  95.  *
  96. -
  97.  * Additionally, the field values can be iterated with foreach
  98. -
  99.  *
  100. -
  101.  * <code>
  102. -
  103.  * foreach ($document as $fieldName => $fieldValue)
  104. -
  105.  * {
  106. -
  107.  * ...
  108. -
  109.  * }
  110. -
  111.  * </code>
  112. -
  113.  */
  114. -
  115. class Apache_Solr_Document implements IteratorAggregate
  116. -
  117. {
  118. -
  119.     /**
  120. -
  121.      * SVN Revision meta data for this class
  122. -
  123.      */
  124. -
  125.     const SVN_REVISION '$Revision: 54 $';
  126. -
  127.  
  128. -
  129.     /**
  130. -
  131.      * SVN ID meta data for this class
  132. -
  133.      */
  134. -
  135.     const SVN_ID '$Id: Document.php 54 2011-02-04 16:29:18Z donovan.jimenez $';
  136. -
  137.  
  138. -
  139.     /**
  140. -
  141.      * Document boost value
  142. -
  143.      *
  144. -
  145.      * @var float 
  146. -
  147.      */
  148. -
  149.     protected $_documentBoost = false;
  150. -
  151.  
  152. -
  153.     /**
  154. -
  155.      * Document field values, indexed by name
  156. -
  157.      *
  158. -
  159.      * @var array 
  160. -
  161.      */
  162. -
  163.     protected $_fields = array();
  164. -
  165.  
  166. -
  167.     /**
  168. -
  169.      * Document field boost values, indexed by name
  170. -
  171.      *
  172. -
  173.      * @var array array of floats
  174. -
  175.      */
  176. -
  177.     protected $_fieldBoosts = array();
  178. -
  179.  
  180. -
  181.     /**
  182. -
  183.      * Clear all boosts and fields from this document
  184. -
  185.      */
  186. -
  187.     public function clear()
  188. -
  189.     {
  190. -
  191.         $this->_documentBoost = false;
  192. -
  193.  
  194. -
  195.         $this->_fields = array();
  196. -
  197.         $this->_fieldBoosts = array();
  198. -
  199.     }
  200. -
  201.  
  202. -
  203.     /**
  204. -
  205.      * Get current document boost
  206. -
  207.      *
  208. -
  209.      * @return mixed will be false for default, or else a float
  210. -
  211.      */
  212. -
  213.     public function getBoost()
  214. -
  215.     {
  216. -
  217.         return $this->_documentBoost;
  218. -
  219.     }
  220. -
  221.  
  222. -
  223.     /**
  224. -
  225.      * Set document boost factor
  226. -
  227.      *
  228. -
  229.      * @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false
  230. -
  231.      */
  232. -
  233.     public function setBoost($boost)
  234. -
  235.     {
  236. -
  237.         $boost = (float) $boost;
  238. -
  239.  
  240. -
  241.         if ($boost 0.0)
  242. -
  243.         {
  244. -
  245.             $this->_documentBoost = $boost;
  246. -
  247.         }
  248. -
  249.         else
  250. -
  251.         {
  252. -
  253.             $this->_documentBoost = false;
  254. -
  255.         }
  256. -
  257.     }
  258. -
  259.  
  260. -
  261.     /**
  262. -
  263.      * Add a value to a multi-valued field
  264. -
  265.      *
  266. -
  267.      * NOTE: the solr XML format allows you to specify boosts
  268. -
  269.      * PER value even though the underlying Lucene implementation
  270. -
  271.      * only allows a boost per field. To remedy this, the final
  272. -
  273.      * field boost value will be the product of all specified boosts
  274. -
  275.      * on field values - this is similar to SolrJ's functionality.
  276. -
  277.      *
  278. -
  279.      * <code>
  280. -
  281.      * $doc = new Apache_Solr_Document();
  282. -
  283.      *
  284. -
  285.      * $doc->addField('foo', 'bar', 2.0);
  286. -
  287.      * $doc->addField('foo', 'baz', 3.0);
  288. -
  289.      *
  290. -
  291.      * // resultant field boost will be 6!
  292. -
  293.      * echo $doc->getFieldBoost('foo');
  294. -
  295.      * </code>
  296. -
  297.      *
  298. -
  299.      * @param string $key 
  300. -
  301.      * @param mixed $value 
  302. -
  303.      * @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false
  304. -
  305.      */
  306. -
  307.     public function addField($key$value$boost false)
  308. -
  309.     {
  310. -
  311.         if (!isset($this->_fields[$key]))
  312. -
  313.         {
  314. -
  315.             // create holding array if this is the first value
  316. -
  317.             $this->_fields[$keyarray();
  318. -
  319.         }
  320. -
  321.         else if (!is_array($this->_fields[$key]))
  322. -
  323.         {
  324. -
  325.             // move existing value into array if it is not already an array
  326. -
  327.             $this->_fields[$keyarray($this->_fields[$key]);
  328. -
  329.         }
  330. -
  331.  
  332. -
  333.         if ($this->getFieldBoost($key=== false)
  334. -
  335.         {
  336. -
  337.             // boost not already set, set it now
  338. -
  339.             $this->setFieldBoost($key$boost);
  340. -
  341.         }
  342. -
  343.         else if ((float) $boost 0.0)
  344. -
  345.         {
  346. -
  347.             // multiply passed boost with current field boost - similar to SolrJ implementation
  348. -
  349.             $this->_fieldBoosts[$key*= (float) $boost;
  350. -
  351.         }
  352. -
  353.  
  354. -
  355.         // add value to array
  356. -
  357.         $this->_fields[$key][$value;
  358. -
  359.     }
  360. -
  361.  
  362. -
  363.     /**
  364. -
  365.      * Handle the array manipulation for a multi-valued field
  366. -
  367.      *
  368. -
  369.      * @param string $key 
  370. -
  371.      * @param string $value 
  372. -
  373.      * @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false
  374. -
  375.      *
  376. -
  377.      * @deprecated Use addField(...) instead
  378. -
  379.      */
  380. -
  381.     public function setMultiValue($key$value$boost false)
  382. -
  383.     {
  384. -
  385.         $this->addField($key$value$boost);
  386. -
  387.     }
  388. -
  389.  
  390. -
  391.     /**
  392. -
  393.      * Get field information
  394. -
  395.      *
  396. -
  397.      * @param string $key 
  398. -
  399.      * @return mixed associative array of info if field exists, false otherwise
  400. -
  401.      */
  402. -
  403.     public function getField($key)
  404. -
  405.     {
  406. -
  407.         if (isset($this->_fields[$key]))
  408. -
  409.         {
  410. -
  411.             return array(
  412. -
  413.                 'name' => $key,
  414. -
  415.                 'value' => $this->_fields[$key],
  416. -
  417.                 'boost' => $this->getFieldBoost($key)
  418. -
  419.             );
  420. -
  421.         }
  422. -
  423.  
  424. -
  425.         return false;
  426. -
  427.     }
  428. -
  429.  
  430. -
  431.     /**
  432. -
  433.      * Set a field value. Multi-valued fields should be set as arrays
  434. -
  435.      * or instead use the addField(...) function which will automatically
  436. -
  437.      * make sure the field is an array.
  438. -
  439.      *
  440. -
  441.      * @param string $key 
  442. -
  443.      * @param mixed $value 
  444. -
  445.      * @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false
  446. -
  447.      */
  448. -
  449.     public function setField($key$value$boost false)
  450. -
  451.     {
  452. -
  453.         $this->_fields[$key$value;
  454. -
  455.         $this->setFieldBoost($key$boost);
  456. -
  457.     }
  458. -
  459.  
  460. -
  461.     /**
  462. -
  463.      * Get the currently set field boost for a document field
  464. -
  465.      *
  466. -
  467.      * @param string $key 
  468. -
  469.      * @return float currently set field boost, false if one is not set
  470. -
  471.      */
  472. -
  473.     public function getFieldBoost($key)
  474. -
  475.     {
  476. -
  477.         return isset($this->_fieldBoosts[$key]$this->_fieldBoosts[$keyfalse;
  478. -
  479.     }
  480. -
  481.  
  482. -
  483.     /**
  484. -
  485.      * Set the field boost for a document field
  486. -
  487.      *
  488. -
  489.      * @param string $key field name for the boost
  490. -
  491.      * @param mixed $boost Use false for default boost, else cast to float that should be > 0 or will be treated as false
  492. -
  493.      */
  494. -
  495.     public function setFieldBoost($key$boost)
  496. -
  497.     {
  498. -
  499.         $boost = (float) $boost;
  500. -
  501.  
  502. -
  503.         if ($boost 0.0)
  504. -
  505.         {
  506. -
  507.             $this->_fieldBoosts[$key$boost;
  508. -
  509.         }
  510. -
  511.         else
  512. -
  513.         {
  514. -
  515.             $this->_fieldBoosts[$keyfalse;
  516. -
  517.         }
  518. -
  519.     }
  520. -
  521.  
  522. -
  523.     /**
  524. -
  525.      * Return current field boosts, indexed by field name
  526. -
  527.      *
  528. -
  529.      * @return array 
  530. -
  531.      */
  532. -
  533.     public function getFieldBoosts()
  534. -
  535.     {
  536. -
  537.         return $this->_fieldBoosts;
  538. -
  539.     }
  540. -
  541.  
  542. -
  543.     /**
  544. -
  545.      * Get the names of all fields in this document
  546. -
  547.      *
  548. -
  549.      * @return array 
  550. -
  551.      */
  552. -
  553.     public function getFieldNames()
  554. -
  555.     {
  556. -
  557.         return array_keys($this->_fields);
  558. -
  559.     }
  560. -
  561.  
  562. -
  563.     /**
  564. -
  565.      * Get the values of all fields in this document
  566. -
  567.      *
  568. -
  569.      * @return array 
  570. -
  571.      */
  572. -
  573.     public function getFieldValues()
  574. -
  575.     {
  576. -
  577.         return array_values($this->_fields);
  578. -
  579.     }
  580. -
  581.  
  582. -
  583.     /**
  584. -
  585.      * IteratorAggregate implementation function. Allows usage:
  586. -
  587.      *
  588. -
  589.      * <code>
  590. -
  591.      * foreach ($document as $key => $value)
  592. -
  593.      * {
  594. -
  595.      *     ...
  596. -
  597.      * }
  598. -
  599.      * </code>
  600. -
  601.      */
  602. -
  603.     public function getIterator()
  604. -
  605.     {
  606. -
  607.         $arrayObject new ArrayObject($this->_fields);
  608. -
  609.  
  610. -
  611.         return $arrayObject->getIterator();
  612. -
  613.     }
  614. -
  615.  
  616. -
  617.     /**
  618. -
  619.      * Magic get for field values
  620. -
  621.      *
  622. -
  623.      * @param string $key 
  624. -
  625.      * @return mixed 
  626. -
  627.      */
  628. -
  629.     public function __get($key)
  630. -
  631.     {
  632. -
  633.         if (isset($this->_fields[$key]))
  634. -
  635.         {
  636. -
  637.             return $this->_fields[$key];
  638. -
  639.         }
  640. -
  641.         
  642. -
  643.         return null;
  644. -
  645.     }
  646. -
  647.  
  648. -
  649.     /**
  650. -
  651.      * Magic set for field values. Multi-valued fields should be set as arrays
  652. -
  653.      * or instead use the addField(...) function which will automatically
  654. -
  655.      * make sure the field is an array.
  656. -
  657.      *
  658. -
  659.      * @param string $key 
  660. -
  661.      * @param mixed $value 
  662. -
  663.      */
  664. -
  665.     public function __set($key$value)
  666. -
  667.     {
  668. -
  669.         $this->setField($key$value);
  670. -
  671.     }
  672. -
  673.  
  674. -
  675.     /**
  676. -
  677.      * Magic isset for fields values.  Do not call directly. Allows usage:
  678. -
  679.      *
  680. -
  681.      * <code>
  682. -
  683.      * isset($document->some_field);
  684. -
  685.      * </code>
  686. -
  687.      *
  688. -
  689.      * @param string $key 
  690. -
  691.      * @return boolean 
  692. -
  693.      */
  694. -
  695.     public function __isset($key)
  696. -
  697.     {
  698. -
  699.         return isset($this->_fields[$key]);
  700. -
  701.     }
  702. -
  703.  
  704. -
  705.     /**
  706. -
  707.      * Magic unset for field values. Do not call directly. Allows usage:
  708. -
  709.      *
  710. -
  711.      * <code>
  712. -
  713.      * unset($document->some_field);
  714. -
  715.      * </code>
  716. -
  717.      *
  718. -
  719.      * @param string $key 
  720. -
  721.      */
  722. -
  723.     public function __unset($key)
  724. -
  725.     {
  726. -
  727.         unset($this->_fields[$key]);
  728. -
  729.         unset($this->_fieldBoosts[$key]);
  730. -
  731.     }
  732. -
  733. }
  734. -
-
-

- Documentation generated on Wed, 04 May 2011 11:01:13 -0400 by phpDocumentor 1.4.3 -

- - \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_Exception.php.html b/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_Exception.php.html deleted file mode 100644 index 956888b3..00000000 --- a/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_Exception.php.html +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - File Source for Exception.php - - - - -

Source for file Exception.php

-

Documentation is available at Exception.php

-
-
  1. <?php
  2. -
  3. /**
  4. -
  5.  * Copyright (c) 2007-2011, Servigistics, Inc.
  6. -
  7.  * All rights reserved.
  8. -
  9.  *
  10. -
  11.  * Redistribution and use in source and binary forms, with or without
  12. -
  13.  * modification, are permitted provided that the following conditions are met:
  14. -
  15.  *
  16. -
  17.  *  - Redistributions of source code must retain the above copyright notice,
  18. -
  19.  *    this list of conditions and the following disclaimer.
  20. -
  21.  *  - Redistributions in binary form must reproduce the above copyright
  22. -
  23.  *    notice, this list of conditions and the following disclaimer in the
  24. -
  25.  *    documentation and/or other materials provided with the distribution.
  26. -
  27.  *  - Neither the name of Servigistics, Inc. nor the names of
  28. -
  29.  *    its contributors may be used to endorse or promote products derived from
  30. -
  31.  *    this software without specific prior written permission.
  32. -
  33.  *
  34. -
  35.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  36. -
  37.  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  38. -
  39.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  40. -
  41.  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  42. -
  43.  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  44. -
  45.  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  46. -
  47.  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  48. -
  49.  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  50. -
  51.  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  52. -
  53.  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  54. -
  55.  * POSSIBILITY OF SUCH DAMAGE.
  56. -
  57.  *
  58. -
  59.  * @copyright Copyright 2007-2011 Servigistics, Inc. (http://servigistics.com)
  60. -
  61.  * @license http://solr-php-client.googlecode.com/svn/trunk/COPYING New BSD
  62. -
  63.  * @version $Id: Exception.php 54 2011-02-04 16:29:18Z donovan.jimenez $
  64. -
  65.  *
  66. -
  67.  * @package Apache
  68. -
  69.  * @subpackage Solr
  70. -
  71.  * @author Donovan Jimenez <djimenez@conduit-it.com>
  72. -
  73.  */
  74. -
  75.  
  76. -
  77. class Apache_Solr_Exception extends Exception
  78. -
  79. {
  80. -
  81.     /**
  82. -
  83.      * SVN Revision meta data for this class
  84. -
  85.      */
  86. -
  87.     const SVN_REVISION = '$Revision: 54 $';
  88. -
  89.  
  90. -
  91.     /**
  92. -
  93.      * SVN ID meta data for this class
  94. -
  95.      */
  96. -
  97.     const SVN_ID = '$Id: Exception.php 54 2011-02-04 16:29:18Z donovan.jimenez $';
  98. -
  99. }
  100. -
-
-

- Documentation generated on Wed, 04 May 2011 11:01:13 -0400 by phpDocumentor 1.4.3 -

- - \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_HttpTransportAbstract.php.html b/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_HttpTransportAbstract.php.html deleted file mode 100644 index 0641914c..00000000 --- a/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_HttpTransportAbstract.php.html +++ /dev/null @@ -1,109 +0,0 @@ - - - - - - File Source for Abstract.php - - - - -

Source for file Abstract.php

-

Documentation is available at Abstract.php

-
-
  1. <?php
  2. -
  3. /**
  4. -
  5.  * Copyright (c) 2007-2011, Servigistics, Inc.
  6. -
  7.  * All rights reserved.
  8. -
  9.  *
  10. -
  11.  * Redistribution and use in source and binary forms, with or without
  12. -
  13.  * modification, are permitted provided that the following conditions are met:
  14. -
  15.  *
  16. -
  17.  *  - Redistributions of source code must retain the above copyright notice,
  18. -
  19.  *    this list of conditions and the following disclaimer.
  20. -
  21.  *  - Redistributions in binary form must reproduce the above copyright
  22. -
  23.  *    notice, this list of conditions and the following disclaimer in the
  24. -
  25.  *    documentation and/or other materials provided with the distribution.
  26. -
  27.  *  - Neither the name of Servigistics, Inc. nor the names of
  28. -
  29.  *    its contributors may be used to endorse or promote products derived from
  30. -
  31.  *    this software without specific prior written permission.
  32. -
  33.  *
  34. -
  35.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  36. -
  37.  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  38. -
  39.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  40. -
  41.  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  42. -
  43.  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  44. -
  45.  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  46. -
  47.  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  48. -
  49.  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  50. -
  51.  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  52. -
  53.  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  54. -
  55.  * POSSIBILITY OF SUCH DAMAGE.
  56. -
  57.  *
  58. -
  59.  * @copyright Copyright 2007-2011 Servigistics, Inc. (http://servigistics.com)
  60. -
  61.  * @license http://solr-php-client.googlecode.com/svn/trunk/COPYING New BSD
  62. -
  63.  * @version $Id: $
  64. -
  65.  *
  66. -
  67.  * @package Apache
  68. -
  69.  * @subpackage Solr
  70. -
  71.  * @author Timo Schmidt <timo.schmidt@aoemedia.de>, Donovan Jimenez <djimenez@conduit-it.com>
  72. -
  73.  */
  74. -
  75.  
  76. -
  77. /**
  78. -
  79.  * Convenience class that implements the transport implementation. Can be extended by
  80. -
  81.  * real implementations to do some of the common book keeping
  82. -
  83.  */
  84. -
  85. abstract class Apache_Solr_HttpTransport_Abstract implements Apache_Solr_HttpTransport_Interface
  86. -
  87. {    
  88. -
  89.     /**
  90. -
  91.      * Our default timeout value for requests that don't specify a timeout
  92. -
  93.      *
  94. -
  95.      * @var float 
  96. -
  97.      */
  98. -
  99.     private $_defaultTimeout false;
  100. -
  101.         
  102. -
  103.     /**
  104. -
  105.      * Get the current default timeout setting (initially the default_socket_timeout ini setting)
  106. -
  107.      * in seconds
  108. -
  109.      *
  110. -
  111.      * @return float 
  112. -
  113.      */
  114. -
  115.     public function getDefaultTimeout()
  116. -
  117.     {
  118. -
  119.         // lazy load the default timeout from the ini settings
  120. -
  121.         if ($this->_defaultTimeout === false)
  122. -
  123.         {
  124. -
  125.             $this->_defaultTimeout = (int) ini_get('default_socket_timeout');
  126. -
  127.  
  128. -
  129.             // double check we didn't get 0 for a timeout
  130. -
  131.             if ($this->_defaultTimeout <= 0)
  132. -
  133.             {
  134. -
  135.                 $this->_defaultTimeout 60;
  136. -
  137.             }
  138. -
  139.         }
  140. -
  141.         
  142. -
  143.         return $this->_defaultTimeout;
  144. -
  145.     }
  146. -
  147.     
  148. -
  149.     /**
  150. -
  151.      * Set the current default timeout for all HTTP requests
  152. -
  153.      *
  154. -
  155.      * @param float $timeout 
  156. -
  157.      */
  158. -
  159.     public function setDefaultTimeout($timeout)
  160. -
  161.     {
  162. -
  163.         $timeout = (float) $timeout;
  164. -
  165.         
  166. -
  167.         if ($timeout >= 0)
  168. -
  169.         {
  170. -
  171.             $this->_defaultTimeout $timeout;
  172. -
  173.         }
  174. -
  175.     }    
  176. -
  177. }
  178. -
-
-

- Documentation generated on Wed, 04 May 2011 11:01:08 -0400 by phpDocumentor 1.4.3 -

- - \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_HttpTransportCurl.php.html b/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_HttpTransportCurl.php.html deleted file mode 100644 index c2489794..00000000 --- a/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_HttpTransportCurl.php.html +++ /dev/null @@ -1,218 +0,0 @@ - - - - - - File Source for Curl.php - - - - -

Source for file Curl.php

-

Documentation is available at Curl.php

-
-
  1. <?php
  2. -
  3. /**
  4. -
  5.  * Copyright (c) 2007-2011, Servigistics, Inc.
  6. -
  7.  * All rights reserved.
  8. -
  9.  *
  10. -
  11.  * Redistribution and use in source and binary forms, with or without
  12. -
  13.  * modification, are permitted provided that the following conditions are met:
  14. -
  15.  *
  16. -
  17.  *  - Redistributions of source code must retain the above copyright notice,
  18. -
  19.  *    this list of conditions and the following disclaimer.
  20. -
  21.  *  - Redistributions in binary form must reproduce the above copyright
  22. -
  23.  *    notice, this list of conditions and the following disclaimer in the
  24. -
  25.  *    documentation and/or other materials provided with the distribution.
  26. -
  27.  *  - Neither the name of Servigistics, Inc. nor the names of
  28. -
  29.  *    its contributors may be used to endorse or promote products derived from
  30. -
  31.  *    this software without specific prior written permission.
  32. -
  33.  *
  34. -
  35.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  36. -
  37.  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  38. -
  39.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  40. -
  41.  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  42. -
  43.  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  44. -
  45.  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  46. -
  47.  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  48. -
  49.  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  50. -
  51.  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  52. -
  53.  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  54. -
  55.  * POSSIBILITY OF SUCH DAMAGE.
  56. -
  57.  *
  58. -
  59.  * @copyright Copyright 2007-2011 Servigistics, Inc. (http://servigistics.com)
  60. -
  61.  * @license http://solr-php-client.googlecode.com/svn/trunk/COPYING New BSD
  62. -
  63.  * @version $Id: $
  64. -
  65.  *
  66. -
  67.  * @package Apache
  68. -
  69.  * @subpackage Solr
  70. -
  71.  * @author Timo Schmidt <timo.schmidt@aoemedia.de>, Donovan Jimenez <djimenez@conduit-it.com>
  72. -
  73.  */
  74. -
  75.  
  76. -
  77. // Require Apache_Solr_HttpTransport_Abstract
  78. -
  79. require_once(dirname(__FILE__'/Abstract.php');
  80. -
  81.  
  82. -
  83. /**
  84. -
  85.  * A Curl based HTTP transport. Uses a single curl session for all requests.
  86. -
  87.  */
  88. -
  89. -
  90. {
  91. -
  92.     /**
  93. -
  94.      * SVN Revision meta data for this class
  95. -
  96.      */
  97. -
  98.     const SVN_REVISION = '$Revision:$';
  99. -
  100.  
  101. -
  102.     /**
  103. -
  104.      * SVN ID meta data for this class
  105. -
  106.      */
  107. -
  108.     const SVN_ID = '$Id:$';
  109. -
  110.  
  111. -
  112.     /**
  113. -
  114.      * Curl Session Handle
  115. -
  116.      *
  117. -
  118.      * @var resource 
  119. -
  120.      */
  121. -
  122.     private $_curl;
  123. -
  124.  
  125. -
  126.     /**
  127. -
  128.      * Initializes a curl session
  129. -
  130.      */
  131. -
  132.     public function __construct()
  133. -
  134.     {
  135. -
  136.         // initialize a CURL session
  137. -
  138.         $this->_curl curl_init();
  139. -
  140.  
  141. -
  142.         // set common options that will not be changed during the session
  143. -
  144.         curl_setopt_array($this->_curlarray(
  145. -
  146.             // return the response body from curl_exec
  147. -
  148.             CURLOPT_RETURNTRANSFER => true,
  149. -
  150.  
  151. -
  152.             // get the output as binary data
  153. -
  154.             CURLOPT_BINARYTRANSFER => true,
  155. -
  156.  
  157. -
  158.             // we do not need the headers in the output, we get everything we need from curl_getinfo
  159. -
  160.             CURLOPT_HEADER => false
  161. -
  162.         ));
  163. -
  164.     }
  165. -
  166.  
  167. -
  168.     /**
  169. -
  170.      * Closes a curl session
  171. -
  172.      */
  173. -
  174.     function __destruct()
  175. -
  176.     {
  177. -
  178.         // close our curl session
  179. -
  180.         curl_close($this->_curl);
  181. -
  182.     }
  183. -
  184.  
  185. -
  186.     public function performGetRequest($url$timeout false)
  187. -
  188.     {
  189. -
  190.         // check the timeout value
  191. -
  192.         if ($timeout === false || $timeout <= 0.0)
  193. -
  194.         {
  195. -
  196.             // use the default timeout
  197. -
  198.             $timeout $this->getDefaultTimeout();
  199. -
  200.         }
  201. -
  202.  
  203. -
  204.         // set curl GET options
  205. -
  206.         curl_setopt_array($this->_curlarray(
  207. -
  208.             // make sure we're returning the body
  209. -
  210.             CURLOPT_NOBODY => false,
  211. -
  212.  
  213. -
  214.             // make sure we're GET
  215. -
  216.             CURLOPT_HTTPGET => true,
  217. -
  218.  
  219. -
  220.             // set the URL
  221. -
  222.             CURLOPT_URL => $url,
  223. -
  224.  
  225. -
  226.             // set the timeout
  227. -
  228.             CURLOPT_TIMEOUT => $timeout
  229. -
  230.         ));
  231. -
  232.  
  233. -
  234.         // make the request
  235. -
  236.         $responseBody curl_exec($this->_curl);
  237. -
  238.  
  239. -
  240.         // get info from the transfer
  241. -
  242.         $statusCode curl_getinfo($this->_curlCURLINFO_HTTP_CODE);
  243. -
  244.         $contentType curl_getinfo($this->_curlCURLINFO_CONTENT_TYPE);
  245. -
  246.  
  247. -
  248.         return new Apache_Solr_HttpTransport_Response($statusCode$contentType$responseBody);
  249. -
  250.     }
  251. -
  252.  
  253. -
  254.     public function performHeadRequest($url$timeout false)
  255. -
  256.     {
  257. -
  258.         // check the timeout value
  259. -
  260.         if ($timeout === false || $timeout <= 0.0)
  261. -
  262.         {
  263. -
  264.             // use the default timeout
  265. -
  266.             $timeout $this->getDefaultTimeout();
  267. -
  268.         }
  269. -
  270.  
  271. -
  272.         // set curl HEAD options
  273. -
  274.         curl_setopt_array($this->_curlarray(
  275. -
  276.             // this both sets the method to HEAD and says not to return a body
  277. -
  278.             CURLOPT_NOBODY => true,
  279. -
  280.  
  281. -
  282.             // set the URL
  283. -
  284.             CURLOPT_URL => $url,
  285. -
  286.  
  287. -
  288.             // set the timeout
  289. -
  290.             CURLOPT_TIMEOUT => $timeout
  291. -
  292.         ));
  293. -
  294.  
  295. -
  296.         // make the request
  297. -
  298.         $responseBody curl_exec($this->_curl);
  299. -
  300.  
  301. -
  302.         // get info from the transfer
  303. -
  304.         $statusCode curl_getinfo($this->_curlCURLINFO_HTTP_CODE);
  305. -
  306.         $contentType curl_getinfo($this->_curlCURLINFO_CONTENT_TYPE);
  307. -
  308.  
  309. -
  310.         return new Apache_Solr_HttpTransport_Response($statusCode$contentType$responseBody);
  311. -
  312.     }
  313. -
  314.  
  315. -
  316.     public function performPostRequest($url$postData$contentType$timeout false)
  317. -
  318.     {
  319. -
  320.         // check the timeout value
  321. -
  322.         if ($timeout === false || $timeout <= 0.0)
  323. -
  324.         {
  325. -
  326.             // use the default timeout
  327. -
  328.             $timeout $this->getDefaultTimeout();
  329. -
  330.         }
  331. -
  332.  
  333. -
  334.         // set curl POST options
  335. -
  336.         curl_setopt_array($this->_curlarray(
  337. -
  338.             // make sure we're returning the body
  339. -
  340.             CURLOPT_NOBODY => false,
  341. -
  342.  
  343. -
  344.             // make sure we're POST
  345. -
  346.             CURLOPT_POST => true,
  347. -
  348.  
  349. -
  350.             // set the URL
  351. -
  352.             CURLOPT_URL => $url,
  353. -
  354.  
  355. -
  356.             // set the post data
  357. -
  358.             CURLOPT_POSTFIELDS => $postData,
  359. -
  360.  
  361. -
  362.             // set the content type
  363. -
  364.             CURLOPT_HTTPHEADER => array("Content-Type: {$contentType}"),
  365. -
  366.  
  367. -
  368.             // set the timeout
  369. -
  370.             CURLOPT_TIMEOUT => $timeout
  371. -
  372.         ));
  373. -
  374.  
  375. -
  376.         // make the request
  377. -
  378.         $responseBody curl_exec($this->_curl);
  379. -
  380.  
  381. -
  382.         // get info from the transfer
  383. -
  384.         $statusCode curl_getinfo($this->_curlCURLINFO_HTTP_CODE);
  385. -
  386.         $contentType curl_getinfo($this->_curlCURLINFO_CONTENT_TYPE);
  387. -
  388.  
  389. -
  390.         return new Apache_Solr_HttpTransport_Response($statusCode$contentType$responseBody);
  391. -
  392.     }
  393. -
  394. }
  395. -
-
-

- Documentation generated on Wed, 04 May 2011 11:01:12 -0400 by phpDocumentor 1.4.3 -

- - \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_HttpTransportCurlNoReuse.php.html b/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_HttpTransportCurlNoReuse.php.html deleted file mode 100644 index 1f772d65..00000000 --- a/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_HttpTransportCurlNoReuse.php.html +++ /dev/null @@ -1,216 +0,0 @@ - - - - - - File Source for CurlNoReuse.php - - - - -

Source for file CurlNoReuse.php

-

Documentation is available at CurlNoReuse.php

-
-
  1. <?php
  2. -
  3. /**
  4. -
  5.  * Copyright (c) 2007-2011, Servigistics, Inc.
  6. -
  7.  * All rights reserved.
  8. -
  9.  *
  10. -
  11.  * Redistribution and use in source and binary forms, with or without
  12. -
  13.  * modification, are permitted provided that the following conditions are met:
  14. -
  15.  *
  16. -
  17.  *  - Redistributions of source code must retain the above copyright notice,
  18. -
  19.  *    this list of conditions and the following disclaimer.
  20. -
  21.  *  - Redistributions in binary form must reproduce the above copyright
  22. -
  23.  *    notice, this list of conditions and the following disclaimer in the
  24. -
  25.  *    documentation and/or other materials provided with the distribution.
  26. -
  27.  *  - Neither the name of Servigistics, Inc. nor the names of
  28. -
  29.  *    its contributors may be used to endorse or promote products derived from
  30. -
  31.  *    this software without specific prior written permission.
  32. -
  33.  *
  34. -
  35.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  36. -
  37.  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  38. -
  39.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  40. -
  41.  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  42. -
  43.  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  44. -
  45.  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  46. -
  47.  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  48. -
  49.  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  50. -
  51.  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  52. -
  53.  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  54. -
  55.  * POSSIBILITY OF SUCH DAMAGE.
  56. -
  57.  *
  58. -
  59.  * @copyright Copyright 2007-2011 Servigistics, Inc. (http://servigistics.com)
  60. -
  61.  * @license http://solr-php-client.googlecode.com/svn/trunk/COPYING New BSD
  62. -
  63.  * @version $Id: $
  64. -
  65.  *
  66. -
  67.  * @package Apache
  68. -
  69.  * @subpackage Solr
  70. -
  71.  * @author Timo Schmidt <timo.schmidt@aoemedia.de>, Donovan Jimenez <djimenez@conduit-it.com>
  72. -
  73.  */
  74. -
  75.  
  76. -
  77. // Require Apache_Solr_HttpTransport_Abstract
  78. -
  79. require_once(dirname(__FILE__'/Abstract.php');
  80. -
  81.  
  82. -
  83. /**
  84. -
  85.  * An alternative Curl HTTP transport that opens and closes a curl session for
  86. -
  87.  * every request. This isn't the recommended way to use curl, but some version of
  88. -
  89.  * PHP have memory issues.
  90. -
  91.  */
  92. -
  93. -
  94. {
  95. -
  96.     /**
  97. -
  98.      * SVN Revision meta data for this class
  99. -
  100.      */
  101. -
  102.     const SVN_REVISION = '$Revision:$';
  103. -
  104.  
  105. -
  106.     /**
  107. -
  108.      * SVN ID meta data for this class
  109. -
  110.      */
  111. -
  112.     const SVN_ID = '$Id:$';
  113. -
  114.  
  115. -
  116.     public function performGetRequest($url$timeout false)
  117. -
  118.     {
  119. -
  120.         // check the timeout value
  121. -
  122.         if ($timeout === false || $timeout <= 0.0)
  123. -
  124.         {
  125. -
  126.             // use the default timeout
  127. -
  128.             $timeout $this->getDefaultTimeout();
  129. -
  130.         }
  131. -
  132.         
  133. -
  134.         $curl curl_init();
  135. -
  136.  
  137. -
  138.         // set curl GET options
  139. -
  140.         curl_setopt_array($curlarray(
  141. -
  142.             // return the response body from curl_exec
  143. -
  144.             CURLOPT_RETURNTRANSFER => true,
  145. -
  146.  
  147. -
  148.             // get the output as binary data
  149. -
  150.             CURLOPT_BINARYTRANSFER => true,
  151. -
  152.  
  153. -
  154.             // we do not need the headers in the output, we get everything we need from curl_getinfo
  155. -
  156.             CURLOPT_HEADER => false,
  157. -
  158.             
  159. -
  160.             // set the URL
  161. -
  162.             CURLOPT_URL => $url,
  163. -
  164.  
  165. -
  166.             // set the timeout
  167. -
  168.             CURLOPT_TIMEOUT => $timeout
  169. -
  170.         ));
  171. -
  172.  
  173. -
  174.         // make the request
  175. -
  176.         $responseBody curl_exec($curl);
  177. -
  178.  
  179. -
  180.         // get info from the transfer
  181. -
  182.         $statusCode curl_getinfo($curlCURLINFO_HTTP_CODE);
  183. -
  184.         $contentType curl_getinfo($curlCURLINFO_CONTENT_TYPE);
  185. -
  186.         
  187. -
  188.         // close our curl session - we're done with it
  189. -
  190.         curl_close($curl);
  191. -
  192.  
  193. -
  194.         return new Apache_Solr_HttpTransport_Response($statusCode$contentType$responseBody);
  195. -
  196.     }
  197. -
  198.  
  199. -
  200.     public function performHeadRequest($url$timeout false)
  201. -
  202.     {
  203. -
  204.         // check the timeout value
  205. -
  206.         if ($timeout === false || $timeout <= 0.0)
  207. -
  208.         {
  209. -
  210.             // use the default timeout
  211. -
  212.             $timeout $this->getDefaultTimeout();
  213. -
  214.         }
  215. -
  216.         
  217. -
  218.         $curl curl_init();
  219. -
  220.  
  221. -
  222.         // set curl HEAD options
  223. -
  224.         curl_setopt_array($curlarray(
  225. -
  226.             // return the response body from curl_exec
  227. -
  228.             CURLOPT_RETURNTRANSFER => true,
  229. -
  230.  
  231. -
  232.             // get the output as binary data
  233. -
  234.             CURLOPT_BINARYTRANSFER => true,
  235. -
  236.  
  237. -
  238.             // we do not need the headers in the output, we get everything we need from curl_getinfo
  239. -
  240.             CURLOPT_HEADER => false,
  241. -
  242.             
  243. -
  244.             // this both sets the method to HEAD and says not to return a body
  245. -
  246.             CURLOPT_NOBODY => true,
  247. -
  248.  
  249. -
  250.             // set the URL
  251. -
  252.             CURLOPT_URL => $url,
  253. -
  254.  
  255. -
  256.             // set the timeout
  257. -
  258.             CURLOPT_TIMEOUT => $timeout
  259. -
  260.         ));
  261. -
  262.  
  263. -
  264.         // make the request
  265. -
  266.         $responseBody curl_exec($curl);
  267. -
  268.  
  269. -
  270.         // get info from the transfer
  271. -
  272.         $statusCode curl_getinfo($curlCURLINFO_HTTP_CODE);
  273. -
  274.         $contentType curl_getinfo($curlCURLINFO_CONTENT_TYPE);
  275. -
  276.         
  277. -
  278.         // close our curl session - we're done with it
  279. -
  280.         curl_close($curl);
  281. -
  282.  
  283. -
  284.         return new Apache_Solr_HttpTransport_Response($statusCode$contentType$responseBody);
  285. -
  286.     }
  287. -
  288.  
  289. -
  290.     public function performPostRequest($url$postData$contentType$timeout false)
  291. -
  292.     {
  293. -
  294.         // check the timeout value
  295. -
  296.         if ($timeout === false || $timeout <= 0.0)
  297. -
  298.         {
  299. -
  300.             // use the default timeout
  301. -
  302.             $timeout $this->getDefaultTimeout();
  303. -
  304.         }
  305. -
  306.  
  307. -
  308.         $curl curl_init();
  309. -
  310.         
  311. -
  312.         // set curl POST options
  313. -
  314.         curl_setopt_array($curlarray(
  315. -
  316.             // return the response body from curl_exec
  317. -
  318.             CURLOPT_RETURNTRANSFER => true,
  319. -
  320.  
  321. -
  322.             // get the output as binary data
  323. -
  324.             CURLOPT_BINARYTRANSFER => true,
  325. -
  326.  
  327. -
  328.             // we do not need the headers in the output, we get everything we need from curl_getinfo
  329. -
  330.             CURLOPT_HEADER => false,
  331. -
  332.             
  333. -
  334.             // make sure we're POST
  335. -
  336.             CURLOPT_POST => true,
  337. -
  338.  
  339. -
  340.             // set the URL
  341. -
  342.             CURLOPT_URL => $url,
  343. -
  344.  
  345. -
  346.             // set the post data
  347. -
  348.             CURLOPT_POSTFIELDS => $postData,
  349. -
  350.  
  351. -
  352.             // set the content type
  353. -
  354.             CURLOPT_HTTPHEADER => array("Content-Type: {$contentType}"),
  355. -
  356.  
  357. -
  358.             // set the timeout
  359. -
  360.             CURLOPT_TIMEOUT => $timeout
  361. -
  362.         ));
  363. -
  364.  
  365. -
  366.         // make the request
  367. -
  368.         $responseBody curl_exec($curl);
  369. -
  370.  
  371. -
  372.         // get info from the transfer
  373. -
  374.         $statusCode curl_getinfo($curlCURLINFO_HTTP_CODE);
  375. -
  376.         $contentType curl_getinfo($curlCURLINFO_CONTENT_TYPE);
  377. -
  378.  
  379. -
  380.         // close our curl session - we're done with it
  381. -
  382.         curl_close($curl);
  383. -
  384.  
  385. -
  386.         return new Apache_Solr_HttpTransport_Response($statusCode$contentType$responseBody);
  387. -
  388.     }
  389. -
  390. }
  391. -
-
-

- Documentation generated on Wed, 04 May 2011 11:01:13 -0400 by phpDocumentor 1.4.3 -

- - \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_HttpTransportException.php.html b/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_HttpTransportException.php.html deleted file mode 100644 index b51a64f3..00000000 --- a/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_HttpTransportException.php.html +++ /dev/null @@ -1,99 +0,0 @@ - - - - - - File Source for HttpTransportException.php - - - - -

Source for file HttpTransportException.php

-

Documentation is available at HttpTransportException.php

-
-
  1. <?php
  2. -
  3. /**
  4. -
  5.  * Copyright (c) 2007-2011, Servigistics, Inc.
  6. -
  7.  * All rights reserved.
  8. -
  9.  *
  10. -
  11.  * Redistribution and use in source and binary forms, with or without
  12. -
  13.  * modification, are permitted provided that the following conditions are met:
  14. -
  15.  *
  16. -
  17.  *  - Redistributions of source code must retain the above copyright notice,
  18. -
  19.  *    this list of conditions and the following disclaimer.
  20. -
  21.  *  - Redistributions in binary form must reproduce the above copyright
  22. -
  23.  *    notice, this list of conditions and the following disclaimer in the
  24. -
  25.  *    documentation and/or other materials provided with the distribution.
  26. -
  27.  *  - Neither the name of Servigistics, Inc. nor the names of
  28. -
  29.  *    its contributors may be used to endorse or promote products derived from
  30. -
  31.  *    this software without specific prior written permission.
  32. -
  33.  *
  34. -
  35.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  36. -
  37.  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  38. -
  39.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  40. -
  41.  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  42. -
  43.  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  44. -
  45.  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  46. -
  47.  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  48. -
  49.  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  50. -
  51.  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  52. -
  53.  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  54. -
  55.  * POSSIBILITY OF SUCH DAMAGE.
  56. -
  57.  *
  58. -
  59.  * @copyright Copyright 2007-2011 Servigistics, Inc. (http://servigistics.com)
  60. -
  61.  * @license http://solr-php-client.googlecode.com/svn/trunk/COPYING New BSD
  62. -
  63.  * @version $Id: HttpTransportException.php 54 2011-02-04 16:29:18Z donovan.jimenez $
  64. -
  65.  *
  66. -
  67.  * @package Apache
  68. -
  69.  * @subpackage Solr
  70. -
  71.  * @author Donovan Jimenez <djimenez@conduit-it.com>
  72. -
  73.  */
  74. -
  75.  
  76. -
  77. -
  78. {
  79. -
  80.     /**
  81. -
  82.      * SVN Revision meta data for this class
  83. -
  84.      */
  85. -
  86.     const SVN_REVISION = '$Revision: 54 $';
  87. -
  88.  
  89. -
  90.     /**
  91. -
  92.      * SVN ID meta data for this class
  93. -
  94.      */
  95. -
  96.     const SVN_ID = '$Id: HttpTransportException.php 54 2011-02-04 16:29:18Z donovan.jimenez $';
  97. -
  98.  
  99. -
  100.     /**
  101. -
  102.      * Response for which exception was generated
  103. -
  104.      *
  105. -
  106.      * @var Apache_Solr_Response 
  107. -
  108.      */
  109. -
  110.     private $_response;
  111. -
  112.  
  113. -
  114.     /**
  115. -
  116.      * HttpTransportException Constructor
  117. -
  118.      *
  119. -
  120.      * @param Apache_Solr_Response $response 
  121. -
  122.      */
  123. -
  124.     public function __construct(Apache_Solr_Response $response)
  125. -
  126.     {
  127. -
  128.         parent::__construct("'{$response->getHttpStatus()}' Status: {$response->getHttpStatusMessage()}"$response->getHttpStatus());
  129. -
  130.  
  131. -
  132.         $this->_response $response;
  133. -
  134.     }
  135. -
  136.  
  137. -
  138.     /**
  139. -
  140.      * Get the response for which this exception was generated
  141. -
  142.      *
  143. -
  144.      * @return Apache_Solr_Response 
  145. -
  146.      */
  147. -
  148.     public function getResponse()
  149. -
  150.     {
  151. -
  152.         return $this->_response;
  153. -
  154.     }
  155. -
  156. }
  157. -
-
-

- Documentation generated on Wed, 04 May 2011 11:01:14 -0400 by phpDocumentor 1.4.3 -

- - \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_HttpTransportFileGetContents.php.html b/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_HttpTransportFileGetContents.php.html deleted file mode 100644 index 1a005cd2..00000000 --- a/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_HttpTransportFileGetContents.php.html +++ /dev/null @@ -1,236 +0,0 @@ - - - - - - File Source for FileGetContents.php - - - - -

Source for file FileGetContents.php

-

Documentation is available at FileGetContents.php

-
-
  1. <?php
  2. -
  3. /**
  4. -
  5.  * Copyright (c) 2007-2011, Servigistics, Inc.
  6. -
  7.  * All rights reserved.
  8. -
  9.  *
  10. -
  11.  * Redistribution and use in source and binary forms, with or without
  12. -
  13.  * modification, are permitted provided that the following conditions are met:
  14. -
  15.  *
  16. -
  17.  *  - Redistributions of source code must retain the above copyright notice,
  18. -
  19.  *    this list of conditions and the following disclaimer.
  20. -
  21.  *  - Redistributions in binary form must reproduce the above copyright
  22. -
  23.  *    notice, this list of conditions and the following disclaimer in the
  24. -
  25.  *    documentation and/or other materials provided with the distribution.
  26. -
  27.  *  - Neither the name of Servigistics, Inc. nor the names of
  28. -
  29.  *    its contributors may be used to endorse or promote products derived from
  30. -
  31.  *    this software without specific prior written permission.
  32. -
  33.  *
  34. -
  35.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  36. -
  37.  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  38. -
  39.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  40. -
  41.  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  42. -
  43.  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  44. -
  45.  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  46. -
  47.  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  48. -
  49.  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  50. -
  51.  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  52. -
  53.  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  54. -
  55.  * POSSIBILITY OF SUCH DAMAGE.
  56. -
  57.  *
  58. -
  59.  * @copyright Copyright 2007-2011 Servigistics, Inc. (http://servigistics.com)
  60. -
  61.  * @license http://solr-php-client.googlecode.com/svn/trunk/COPYING New BSD
  62. -
  63.  * @version $Id: $
  64. -
  65.  *
  66. -
  67.  * @package Apache
  68. -
  69.  * @subpackage Solr
  70. -
  71.  * @author Donovan Jimenez <djimenez@conduit-it.com>
  72. -
  73.  */
  74. -
  75.  
  76. -
  77. // Require Apache_Solr_HttpTransport_Abstract
  78. -
  79. require_once(dirname(__FILE__'/Abstract.php');
  80. -
  81.  
  82. -
  83. /**
  84. -
  85.  * HTTP Transport implemenation that uses the builtin http URL wrappers and file_get_contents
  86. -
  87.  */
  88. -
  89. -
  90. {
  91. -
  92.     /**
  93. -
  94.      * SVN Revision meta data for this class
  95. -
  96.      */
  97. -
  98.     const SVN_REVISION = '$Revision:  $';
  99. -
  100.  
  101. -
  102.     /**
  103. -
  104.      * SVN ID meta data for this class
  105. -
  106.      */
  107. -
  108.     const SVN_ID = '$Id:  $';
  109. -
  110.         
  111. -
  112.     /**
  113. -
  114.      * Reusable stream context resources for GET and POST operations
  115. -
  116.      *
  117. -
  118.      * @var resource 
  119. -
  120.      */
  121. -
  122.     private $_getContext$_headContext$_postContext;
  123. -
  124.     
  125. -
  126.     /**
  127. -
  128.      * Initializes our reuseable get and post stream contexts
  129. -
  130.      */
  131. -
  132.     public function __construct()
  133. -
  134.     {
  135. -
  136.         $this->_getContext stream_context_create();
  137. -
  138.         $this->_headContext stream_context_create();
  139. -
  140.         $this->_postContext stream_context_create();
  141. -
  142.     }
  143. -
  144.  
  145. -
  146.     public function performGetRequest($url$timeout false)
  147. -
  148.     {
  149. -
  150.         // set the timeout if specified
  151. -
  152.         if ($timeout !== FALSE && $timeout 0.0)
  153. -
  154.         {
  155. -
  156.             // timeouts with file_get_contents seem to need
  157. -
  158.             // to be halved to work as expected
  159. -
  160.             $timeout = (float) $timeout 2;
  161. -
  162.  
  163. -
  164.             stream_context_set_option($this->_getContext'http''timeout'$timeout);
  165. -
  166.         }
  167. -
  168.         else
  169. -
  170.         {
  171. -
  172.             // use the default timeout pulled from default_socket_timeout otherwise
  173. -
  174.             stream_context_set_option($this->_getContext'http''timeout'$this->getDefaultTimeout());
  175. -
  176.         }
  177. -
  178.  
  179. -
  180.         // $http_response_headers will be updated by the call to file_get_contents later
  181. -
  182.         // see http://us.php.net/manual/en/wrappers.http.php for documentation
  183. -
  184.         // Unfortunately, it will still create a notice in analyzers if we don't set it here
  185. -
  186.         $http_response_header null;
  187. -
  188.         $responseBody @file_get_contents($urlfalse$this->_getContext);
  189. -
  190.         
  191. -
  192.         return $this->_getResponseFromParts($responseBody$http_response_header);
  193. -
  194.     }
  195. -
  196.  
  197. -
  198.     public function performHeadRequest($url$timeout false)
  199. -
  200.     {
  201. -
  202.         stream_context_set_option($this->_headContextarray(
  203. -
  204.                 'http' => array(
  205. -
  206.                     // set HTTP method
  207. -
  208.                     'method' => 'HEAD',
  209. -
  210.  
  211. -
  212.                     // default timeout
  213. -
  214.                     'timeout' => $this->getDefaultTimeout()
  215. -
  216.                 )
  217. -
  218.             )
  219. -
  220.         );
  221. -
  222.  
  223. -
  224.         // set the timeout if specified
  225. -
  226.         if ($timeout !== FALSE && $timeout 0.0)
  227. -
  228.         {
  229. -
  230.             // timeouts with file_get_contents seem to need
  231. -
  232.             // to be halved to work as expected
  233. -
  234.             $timeout = (float) $timeout 2;
  235. -
  236.  
  237. -
  238.             stream_context_set_option($this->_headContext'http''timeout'$timeout);
  239. -
  240.         }
  241. -
  242.         
  243. -
  244.         // $http_response_headers will be updated by the call to file_get_contents later
  245. -
  246.         // see http://us.php.net/manual/en/wrappers.http.php for documentation
  247. -
  248.         // Unfortunately, it will still create a notice in analyzers if we don't set it here
  249. -
  250.         $http_response_header null;
  251. -
  252.         $responseBody @file_get_contents($urlfalse$this->_headContext);
  253. -
  254.  
  255. -
  256.         return $this->_getResponseFromParts($responseBody$http_response_header);
  257. -
  258.     }
  259. -
  260.     
  261. -
  262.     public function performPostRequest($url$rawPost$contentType$timeout false)
  263. -
  264.     {
  265. -
  266.         stream_context_set_option($this->_postContextarray(
  267. -
  268.                 'http' => array(
  269. -
  270.                     // set HTTP method
  271. -
  272.                     'method' => 'POST',
  273. -
  274.  
  275. -
  276.                     // Add our posted content type
  277. -
  278.                     'header' => "Content-Type: $contentType",
  279. -
  280.  
  281. -
  282.                     // the posted content
  283. -
  284.                     'content' => $rawPost,
  285. -
  286.  
  287. -
  288.                     // default timeout
  289. -
  290.                     'timeout' => $this->getDefaultTimeout()
  291. -
  292.                 )
  293. -
  294.             )
  295. -
  296.         );
  297. -
  298.  
  299. -
  300.         // set the timeout if specified
  301. -
  302.         if ($timeout !== FALSE && $timeout 0.0)
  303. -
  304.         {
  305. -
  306.             // timeouts with file_get_contents seem to need
  307. -
  308.             // to be halved to work as expected
  309. -
  310.             $timeout = (float) $timeout 2;
  311. -
  312.  
  313. -
  314.             stream_context_set_option($this->_postContext'http''timeout'$timeout);
  315. -
  316.         }
  317. -
  318.  
  319. -
  320.         // $http_response_header will be updated by the call to file_get_contents later
  321. -
  322.         // see http://us.php.net/manual/en/wrappers.http.php for documentation
  323. -
  324.         // Unfortunately, it will still create a notice in analyzers if we don't set it here
  325. -
  326.         $http_response_header null;
  327. -
  328.         $responseBody @file_get_contents($urlfalse$this->_postContext);
  329. -
  330.         
  331. -
  332.         // reset content of post context to reclaim memory
  333. -
  334.         stream_context_set_option($this->_postContext'http''content''');
  335. -
  336.         
  337. -
  338.         return $this->_getResponseFromParts($responseBody$http_response_header);
  339. -
  340.     }
  341. -
  342.     
  343. -
  344.     private function _getResponseFromParts($rawResponse$httpHeaders)
  345. -
  346.     {
  347. -
  348.         //Assume 0, false as defaults
  349. -
  350.         $status 0;
  351. -
  352.         $contentType false;
  353. -
  354.  
  355. -
  356.         //iterate through headers for real status, type, and encoding
  357. -
  358.         if (is_array($httpHeaders&& count($httpHeaders0)
  359. -
  360.         {
  361. -
  362.             //look at the first headers for the HTTP status code
  363. -
  364.             //and message (errors are usually returned this way)
  365. -
  366.             //
  367. -
  368.             //HTTP 100 Continue response can also be returned before
  369. -
  370.             //the REAL status header, so we need look until we find
  371. -
  372.             //the last header starting with HTTP
  373. -
  374.             //
  375. -
  376.             //the spec: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.1
  377. -
  378.             //
  379. -
  380.             //Thanks to Daniel Andersson for pointing out this oversight
  381. -
  382.             while (isset($httpHeaders[0]&& substr($httpHeaders[0]04== 'HTTP')
  383. -
  384.             {
  385. -
  386.                 // we can do a intval on status line without the "HTTP/1.X " to get the code
  387. -
  388.                 $status intval(substr($httpHeaders[0]9));
  389. -
  390.  
  391. -
  392.                 // remove this from the headers so we can check for more
  393. -
  394.                 array_shift($httpHeaders);
  395. -
  396.             }
  397. -
  398.  
  399. -
  400.             //Look for the Content-Type response header and determine type
  401. -
  402.             //and encoding from it (if possible - such as 'Content-Type: text/plain; charset=UTF-8')
  403. -
  404.             foreach ($httpHeaders as $header)
  405. -
  406.             {
  407. -
  408.                 // look for the header that starts appropriately
  409. -
  410.                 if (strncasecmp($header'Content-Type:'13== 0)
  411. -
  412.                 {
  413. -
  414.                     $contentType substr($header13);
  415. -
  416.                     break;
  417. -
  418.                 }
  419. -
  420.             }
  421. -
  422.         }
  423. -
  424.         
  425. -
  426.         return new Apache_Solr_HttpTransport_Response($status$contentType$rawResponse);
  427. -
  428.     }
  429. -
  430. }
  431. -
-
-

- Documentation generated on Wed, 04 May 2011 11:01:14 -0400 by phpDocumentor 1.4.3 -

- - \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_HttpTransportInterface.php.html b/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_HttpTransportInterface.php.html deleted file mode 100644 index 24be1b05..00000000 --- a/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_HttpTransportInterface.php.html +++ /dev/null @@ -1,114 +0,0 @@ - - - - - - File Source for Interface.php - - - - -

Source for file Interface.php

-

Documentation is available at Interface.php

-
-
  1. <?php
  2. -
  3. /**
  4. -
  5.  * Copyright (c) 2007-2011, Servigistics, Inc.
  6. -
  7.  * All rights reserved.
  8. -
  9.  *
  10. -
  11.  * Redistribution and use in source and binary forms, with or without
  12. -
  13.  * modification, are permitted provided that the following conditions are met:
  14. -
  15.  *
  16. -
  17.  *  - Redistributions of source code must retain the above copyright notice,
  18. -
  19.  *    this list of conditions and the following disclaimer.
  20. -
  21.  *  - Redistributions in binary form must reproduce the above copyright
  22. -
  23.  *    notice, this list of conditions and the following disclaimer in the
  24. -
  25.  *    documentation and/or other materials provided with the distribution.
  26. -
  27.  *  - Neither the name of Servigistics, Inc. nor the names of
  28. -
  29.  *    its contributors may be used to endorse or promote products derived from
  30. -
  31.  *    this software without specific prior written permission.
  32. -
  33.  *
  34. -
  35.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  36. -
  37.  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  38. -
  39.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  40. -
  41.  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  42. -
  43.  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  44. -
  45.  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  46. -
  47.  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  48. -
  49.  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  50. -
  51.  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  52. -
  53.  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  54. -
  55.  * POSSIBILITY OF SUCH DAMAGE.
  56. -
  57.  *
  58. -
  59.  * @copyright Copyright 2007-2011 Servigistics, Inc. (http://servigistics.com)
  60. -
  61.  * @license http://solr-php-client.googlecode.com/svn/trunk/COPYING New BSD
  62. -
  63.  * @version $Id: $
  64. -
  65.  *
  66. -
  67.  * @package Apache
  68. -
  69.  * @subpackage Solr
  70. -
  71.  * @author Timo Schmidt <timo.schmidt@aoemedia.de>, Donovan Jimenez <djimenez@conduit-it.com>
  72. -
  73.  */
  74. -
  75.  
  76. -
  77. // require Apache_Solr_HttpTransport_Response
  78. -
  79. require_once(dirname(__FILE__'/Response.php');
  80. -
  81.  
  82. -
  83. /**
  84. -
  85.  * Interface that all Transport (HTTP Requester) implementations must implement. These
  86. -
  87.  * Implementations can then be plugged into the Service instance in order to user their
  88. -
  89.  * the desired method for making HTTP requests
  90. -
  91.  */
  92. -
  93. -
  94. {
  95. -
  96.     /**
  97. -
  98.      * Get the current default timeout for all HTTP requests
  99. -
  100.      *
  101. -
  102.      * @return float 
  103. -
  104.      */
  105. -
  106.     public function getDefaultTimeout();
  107. -
  108.     
  109. -
  110.     /**
  111. -
  112.      * Set the current default timeout for all HTTP requests
  113. -
  114.      *
  115. -
  116.      * @param float $timeout 
  117. -
  118.      */
  119. -
  120.     public function setDefaultTimeout($timeout);
  121. -
  122.         
  123. -
  124.     /**
  125. -
  126.      * Perform a GET HTTP operation with an optional timeout and return the response
  127. -
  128.      * contents, use getLastResponseHeaders to retrieve HTTP headers
  129. -
  130.      *
  131. -
  132.      * @param string $url 
  133. -
  134.      * @param float $timeout 
  135. -
  136.      * @return Apache_Solr_HttpTransport_Response HTTP response
  137. -
  138.      */
  139. -
  140.     public function performGetRequest($url$timeout false);
  141. -
  142.     
  143. -
  144.     /**
  145. -
  146.      * Perform a HEAD HTTP operation with an optional timeout and return the response
  147. -
  148.      * headers - NOTE: head requests have no response body
  149. -
  150.      *
  151. -
  152.      * @param string $url 
  153. -
  154.      * @param float $timeout 
  155. -
  156.      * @return Apache_Solr_HttpTransport_Response HTTP response
  157. -
  158.      */
  159. -
  160.     public function performHeadRequest($url$timeout false);
  161. -
  162.     
  163. -
  164.     /**
  165. -
  166.      * Perform a POST HTTP operation with an optional timeout and return the response
  167. -
  168.      * contents, use getLastResponseHeaders to retrieve HTTP headers
  169. -
  170.      *
  171. -
  172.      * @param string $url 
  173. -
  174.      * @param string $rawPost 
  175. -
  176.      * @param string $contentType 
  177. -
  178.      * @param float $timeout 
  179. -
  180.      * @return Apache_Solr_HttpTransport_Response HTTP response
  181. -
  182.      */
  183. -
  184.     public function performPostRequest($url$rawPost$contentType$timeout false);
  185. -
  186. }
  187. -
-
-

- Documentation generated on Wed, 04 May 2011 11:01:15 -0400 by phpDocumentor 1.4.3 -

- - \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_HttpTransportResponse.php.html b/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_HttpTransportResponse.php.html deleted file mode 100644 index 4ad92f51..00000000 --- a/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_HttpTransportResponse.php.html +++ /dev/null @@ -1,275 +0,0 @@ - - - - - - File Source for Response.php - - - - -

Source for file Response.php

-

Documentation is available at Response.php

-
-
  1. <?php
  2. -
  3. /**
  4. -
  5.  * Copyright (c) 2007-2011, Servigistics, Inc.
  6. -
  7.  * All rights reserved.
  8. -
  9.  *
  10. -
  11.  * Redistribution and use in source and binary forms, with or without
  12. -
  13.  * modification, are permitted provided that the following conditions are met:
  14. -
  15.  *
  16. -
  17.  *  - Redistributions of source code must retain the above copyright notice,
  18. -
  19.  *    this list of conditions and the following disclaimer.
  20. -
  21.  *  - Redistributions in binary form must reproduce the above copyright
  22. -
  23.  *    notice, this list of conditions and the following disclaimer in the
  24. -
  25.  *    documentation and/or other materials provided with the distribution.
  26. -
  27.  *  - Neither the name of Servigistics, Inc. nor the names of
  28. -
  29.  *    its contributors may be used to endorse or promote products derived from
  30. -
  31.  *    this software without specific prior written permission.
  32. -
  33.  *
  34. -
  35.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  36. -
  37.  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  38. -
  39.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  40. -
  41.  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  42. -
  43.  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  44. -
  45.  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  46. -
  47.  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  48. -
  49.  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  50. -
  51.  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  52. -
  53.  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  54. -
  55.  * POSSIBILITY OF SUCH DAMAGE.
  56. -
  57.  *
  58. -
  59.  * @copyright Copyright 2007-2011 Servigistics, Inc. (http://servigistics.com)
  60. -
  61.  * @license http://solr-php-client.googlecode.com/svn/trunk/COPYING New BSD
  62. -
  63.  * @version $Id: $
  64. -
  65.  *
  66. -
  67.  * @package Apache
  68. -
  69.  * @subpackage Solr
  70. -
  71.  * @author Donovan Jimenez <djimenez@conduit-it.com>
  72. -
  73.  */
  74. -
  75.  
  76. -
  77. /**
  78. -
  79.  * Represents the required pieces of an HTTP response provided by HTTP transport
  80. -
  81.  * implementations and then consumed by the Apache_Solr_Response class which provides
  82. -
  83.  * decoding
  84. -
  85.  */
  86. -
  87. -
  88. {
  89. -
  90.     /**
  91. -
  92.      * Status Messages indexed by Status Code
  93. -
  94.      * Obtained from: http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
  95. -
  96.      *
  97. -
  98.      * @var array 
  99. -
  100.      */
  101. -
  102.     static private $_defaultStatusMessages array(
  103. -
  104.         // Specific to PHP Solr Client
  105. -
  106.         => "Communication Error",
  107. -
  108.         
  109. -
  110.         // Informational 1XX
  111. -
  112.         100 => "Continue",
  113. -
  114.         101 => "Switching Protocols",
  115. -
  116.         
  117. -
  118.         // Successful 2XX
  119. -
  120.         200 => "OK",
  121. -
  122.         201 => "Created",
  123. -
  124.         202 => "Accepted",
  125. -
  126.         203 => "Non-Authoritative Information",
  127. -
  128.         204 => "No Content",
  129. -
  130.         205 => "Reset Content",
  131. -
  132.         206 => "Partial Content",
  133. -
  134.         
  135. -
  136.         // Redirection 3XX
  137. -
  138.         300 => "Multiple Choices",
  139. -
  140.         301 => "Moved Permanently",
  141. -
  142.         302 => "Found",
  143. -
  144.         303 => "See Other",
  145. -
  146.         304 => "Not Modified",
  147. -
  148.         305 => "Use Proxy",
  149. -
  150.         307 => "Temporary Redirect",
  151. -
  152.         
  153. -
  154.         // Client Error 4XX
  155. -
  156.         400 => "Bad Request",
  157. -
  158.         401 => "Unauthorized",
  159. -
  160.         402 => "Payment Required",
  161. -
  162.         403 => "Forbidden",
  163. -
  164.         404 => "Not Found",
  165. -
  166.         405 => "Method Not Allowed",
  167. -
  168.         406 => "Not Acceptable",
  169. -
  170.         407 => "Proxy Authentication Required",
  171. -
  172.         408 => "Request Timeout",
  173. -
  174.         409 => "Conflict",
  175. -
  176.         410 => "Gone",
  177. -
  178.         411 => "Length Required",
  179. -
  180.         412 => "Precondition Failed",
  181. -
  182.         413 => "Request Entity Too Large",
  183. -
  184.         414 => "Request-URI Too Long",
  185. -
  186.         415 => "Unsupported Media Type",
  187. -
  188.         416 => "Request Range Not Satisfiable",
  189. -
  190.         417 => "Expectation Failed",
  191. -
  192.         
  193. -
  194.         // Server Error 5XX
  195. -
  196.         500 => "Internal Server Error",
  197. -
  198.         501 => "Not Implemented",
  199. -
  200.         502 => "Bad Gateway",
  201. -
  202.         503 => "Service Unavailable",
  203. -
  204.         504 => "Gateway Timeout",
  205. -
  206.         505 => "HTTP Version Not Supported"
  207. -
  208.     );
  209. -
  210.     
  211. -
  212.     /**
  213. -
  214.      * Get the HTTP status message based on status code
  215. -
  216.      *
  217. -
  218.      * @return string 
  219. -
  220.      */
  221. -
  222.     public static function getDefaultStatusMessage($statusCode)
  223. -
  224.     {
  225. -
  226.         $statusCode = (int) $statusCode;
  227. -
  228.         
  229. -
  230.         if (isset(self::$_defaultStatusMessages[$statusCode]))
  231. -
  232.         {
  233. -
  234.             return self::$_defaultStatusMessages[$statusCode];
  235. -
  236.         }
  237. -
  238.         
  239. -
  240.         return "Unknown Status";
  241. -
  242.     }
  243. -
  244.     
  245. -
  246.     /**
  247. -
  248.      * The response's HTTP status code
  249. -
  250.      *
  251. -
  252.      * @var integer 
  253. -
  254.      */
  255. -
  256.     private $_statusCode;
  257. -
  258.     
  259. -
  260.     /**
  261. -
  262.      * The response's HTTP status message
  263. -
  264.      *
  265. -
  266.      * @var string 
  267. -
  268.      */
  269. -
  270.     private $_statusMessage;
  271. -
  272.     
  273. -
  274.     /**
  275. -
  276.      * The response's mime type
  277. -
  278.      *
  279. -
  280.      * @var string 
  281. -
  282.      */
  283. -
  284.     private $_mimeType;
  285. -
  286.     
  287. -
  288.     /**
  289. -
  290.      * The response's character encoding
  291. -
  292.      *
  293. -
  294.      * @var string 
  295. -
  296.      */
  297. -
  298.     private $_encoding;
  299. -
  300.     
  301. -
  302.     /**
  303. -
  304.      * The response's data
  305. -
  306.      *
  307. -
  308.      * @var string 
  309. -
  310.      */
  311. -
  312.     private $_responseBody;
  313. -
  314.     
  315. -
  316.     /**
  317. -
  318.      * Construct a HTTP transport response
  319. -
  320.      * 
  321. -
  322.      * @param integer $statusCode The HTTP status code
  323. -
  324.      * @param string $contentType The VALUE of the Content-Type HTTP header
  325. -
  326.      * @param string $responseBody The body of the HTTP response
  327. -
  328.      */
  329. -
  330.     public function __construct($statusCode$contentType$responseBody)
  331. -
  332.     {
  333. -
  334.         // set the status code, make sure its an integer
  335. -
  336.         $this->_statusCode = (int) $statusCode;
  337. -
  338.         
  339. -
  340.         // lookup up status message based on code
  341. -
  342.         $this->_statusMessage self::getDefaultStatusMessage($this->_statusCode);
  343. -
  344.         
  345. -
  346.         // set the response body, it should always be a string
  347. -
  348.         $this->_responseBody = (string) $responseBody;
  349. -
  350.         
  351. -
  352.         // parse the content type header value for mimetype and encoding
  353. -
  354.         // first set default values that will remain if we can't find
  355. -
  356.         // what we're looking for in the content type
  357. -
  358.         $this->_mimeType "text/plain";
  359. -
  360.         $this->_encoding "UTF-8";
  361. -
  362.         
  363. -
  364.         if ($contentType)
  365. -
  366.         {
  367. -
  368.             // now break apart the header to see if there's character encoding
  369. -
  370.             $contentTypeParts explode(';'$contentType2);
  371. -
  372.  
  373. -
  374.             if (isset($contentTypeParts[0]))
  375. -
  376.             {
  377. -
  378.                 $this->_mimeType trim($contentTypeParts[0]);
  379. -
  380.             }
  381. -
  382.  
  383. -
  384.             if (isset($contentTypeParts[1]))
  385. -
  386.             {
  387. -
  388.                 // we have a second part, split it further
  389. -
  390.                 $contentTypeParts explode('='$contentTypeParts[1]);
  391. -
  392.  
  393. -
  394.                 if (isset($contentTypeParts[1]))
  395. -
  396.                 {
  397. -
  398.                     $this->_encoding trim($contentTypeParts[1]);
  399. -
  400.                 }
  401. -
  402.             }
  403. -
  404.         }
  405. -
  406.     }
  407. -
  408.     
  409. -
  410.     /**
  411. -
  412.      * Get the status code of the response
  413. -
  414.      *
  415. -
  416.      * @return integer 
  417. -
  418.      */
  419. -
  420.     public function getStatusCode()
  421. -
  422.     {
  423. -
  424.         return $this->_statusCode;
  425. -
  426.     }
  427. -
  428.     
  429. -
  430.     /**
  431. -
  432.      * Get the status message of the response
  433. -
  434.      *
  435. -
  436.      * @return string 
  437. -
  438.      */
  439. -
  440.     public function getStatusMessage()
  441. -
  442.     {
  443. -
  444.         return $this->_statusMessage;
  445. -
  446.     }
  447. -
  448.     
  449. -
  450.     /**
  451. -
  452.      * Get the mimetype of the response body
  453. -
  454.      *
  455. -
  456.      * @return string 
  457. -
  458.      */
  459. -
  460.     public function getMimeType()
  461. -
  462.     {
  463. -
  464.         return $this->_mimeType;
  465. -
  466.     }
  467. -
  468.     
  469. -
  470.     /**
  471. -
  472.      * Get the charset encoding of the response body.
  473. -
  474.      *
  475. -
  476.      * @return string 
  477. -
  478.      */
  479. -
  480.     public function getEncoding()
  481. -
  482.     {
  483. -
  484.         return $this->_encoding;
  485. -
  486.     }
  487. -
  488.     
  489. -
  490.     /**
  491. -
  492.      * Get the raw response body
  493. -
  494.      *
  495. -
  496.      * @return string 
  497. -
  498.      */
  499. -
  500.     public function getBody()
  501. -
  502.     {
  503. -
  504.         return $this->_responseBody;
  505. -
  506.     }
  507. -
  508. }
  509. -
-
-

- Documentation generated on Wed, 04 May 2011 11:01:16 -0400 by phpDocumentor 1.4.3 -

- - \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_InvalidArgumentException.php.html b/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_InvalidArgumentException.php.html deleted file mode 100644 index 5f7d4e81..00000000 --- a/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_InvalidArgumentException.php.html +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - File Source for InvalidArgumentException.php - - - - -

Source for file InvalidArgumentException.php

-

Documentation is available at InvalidArgumentException.php

-
-
  1. <?php
  2. -
  3. /**
  4. -
  5.  * Copyright (c) 2007-2011, Servigistics, Inc.
  6. -
  7.  * All rights reserved.
  8. -
  9.  *
  10. -
  11.  * Redistribution and use in source and binary forms, with or without
  12. -
  13.  * modification, are permitted provided that the following conditions are met:
  14. -
  15.  *
  16. -
  17.  *  - Redistributions of source code must retain the above copyright notice,
  18. -
  19.  *    this list of conditions and the following disclaimer.
  20. -
  21.  *  - Redistributions in binary form must reproduce the above copyright
  22. -
  23.  *    notice, this list of conditions and the following disclaimer in the
  24. -
  25.  *    documentation and/or other materials provided with the distribution.
  26. -
  27.  *  - Neither the name of Servigistics, Inc. nor the names of
  28. -
  29.  *    its contributors may be used to endorse or promote products derived from
  30. -
  31.  *    this software without specific prior written permission.
  32. -
  33.  *
  34. -
  35.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  36. -
  37.  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  38. -
  39.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  40. -
  41.  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  42. -
  43.  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  44. -
  45.  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  46. -
  47.  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  48. -
  49.  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  50. -
  51.  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  52. -
  53.  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  54. -
  55.  * POSSIBILITY OF SUCH DAMAGE.
  56. -
  57.  *
  58. -
  59.  * @copyright Copyright 2007-2011 Servigistics, Inc. (http://servigistics.com)
  60. -
  61.  * @license http://solr-php-client.googlecode.com/svn/trunk/COPYING New BSD
  62. -
  63.  * @version $Id: InvalidArgumentException.php 54 2011-02-04 16:29:18Z donovan.jimenez $
  64. -
  65.  *
  66. -
  67.  * @package Apache
  68. -
  69.  * @subpackage Solr
  70. -
  71.  * @author Donovan Jimenez <djimenez@conduit-it.com>
  72. -
  73.  */
  74. -
  75.  
  76. -
  77. -
  78. {
  79. -
  80.     /**
  81. -
  82.      * SVN Revision meta data for this class
  83. -
  84.      */
  85. -
  86.     const SVN_REVISION = '$Revision: 54 $';
  87. -
  88.  
  89. -
  90.     /**
  91. -
  92.      * SVN ID meta data for this class
  93. -
  94.      */
  95. -
  96.     const SVN_ID = '$Id: InvalidArgumentException.php 54 2011-02-04 16:29:18Z donovan.jimenez $';
  97. -
  98. }
  99. -
-
-

- Documentation generated on Wed, 04 May 2011 11:01:15 -0400 by phpDocumentor 1.4.3 -

- - \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_NoServiceAvailableException.php.html b/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_NoServiceAvailableException.php.html deleted file mode 100644 index 00a144e7..00000000 --- a/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_NoServiceAvailableException.php.html +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - File Source for NoServiceAvailableException.php - - - - -

Source for file NoServiceAvailableException.php

-

Documentation is available at NoServiceAvailableException.php

-
-
  1. <?php
  2. -
  3. /**
  4. -
  5.  * Copyright (c) 2007-2011, Servigistics, Inc.
  6. -
  7.  * All rights reserved.
  8. -
  9.  *
  10. -
  11.  * Redistribution and use in source and binary forms, with or without
  12. -
  13.  * modification, are permitted provided that the following conditions are met:
  14. -
  15.  *
  16. -
  17.  *  - Redistributions of source code must retain the above copyright notice,
  18. -
  19.  *    this list of conditions and the following disclaimer.
  20. -
  21.  *  - Redistributions in binary form must reproduce the above copyright
  22. -
  23.  *    notice, this list of conditions and the following disclaimer in the
  24. -
  25.  *    documentation and/or other materials provided with the distribution.
  26. -
  27.  *  - Neither the name of Servigistics, Inc. nor the names of
  28. -
  29.  *    its contributors may be used to endorse or promote products derived from
  30. -
  31.  *    this software without specific prior written permission.
  32. -
  33.  *
  34. -
  35.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  36. -
  37.  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  38. -
  39.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  40. -
  41.  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  42. -
  43.  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  44. -
  45.  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  46. -
  47.  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  48. -
  49.  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  50. -
  51.  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  52. -
  53.  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  54. -
  55.  * POSSIBILITY OF SUCH DAMAGE.
  56. -
  57.  *
  58. -
  59.  * @copyright Copyright 2007-2011 Servigistics, Inc. (http://servigistics.com)
  60. -
  61.  * @license http://solr-php-client.googlecode.com/svn/trunk/COPYING New BSD
  62. -
  63.  * @version $Id: NoServiceAvailableException.php 54 2011-02-04 16:29:18Z donovan.jimenez $
  64. -
  65.  *
  66. -
  67.  * @package Apache
  68. -
  69.  * @subpackage Solr
  70. -
  71.  * @author Donovan Jimenez <djimenez@conduit-it.com>
  72. -
  73.  */
  74. -
  75.  
  76. -
  77. -
  78. {
  79. -
  80.     /**
  81. -
  82.      * SVN Revision meta data for this class
  83. -
  84.      */
  85. -
  86.     const SVN_REVISION = '$Revision: 54 $';
  87. -
  88.  
  89. -
  90.     /**
  91. -
  92.      * SVN ID meta data for this class
  93. -
  94.      */
  95. -
  96.     const SVN_ID = '$Id: NoServiceAvailableException.php 54 2011-02-04 16:29:18Z donovan.jimenez $';
  97. -
  98. }
  99. -
-
-

- Documentation generated on Wed, 04 May 2011 11:01:15 -0400 by phpDocumentor 1.4.3 -

- - \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_ParserException.php.html b/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_ParserException.php.html deleted file mode 100644 index 72c0d353..00000000 --- a/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_ParserException.php.html +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - File Source for ParserException.php - - - - -

Source for file ParserException.php

-

Documentation is available at ParserException.php

-
-
  1. <?php
  2. -
  3. /**
  4. -
  5.  * Copyright (c) 2007-2011, Servigistics, Inc.
  6. -
  7.  * All rights reserved.
  8. -
  9.  *
  10. -
  11.  * Redistribution and use in source and binary forms, with or without
  12. -
  13.  * modification, are permitted provided that the following conditions are met:
  14. -
  15.  *
  16. -
  17.  *  - Redistributions of source code must retain the above copyright notice,
  18. -
  19.  *    this list of conditions and the following disclaimer.
  20. -
  21.  *  - Redistributions in binary form must reproduce the above copyright
  22. -
  23.  *    notice, this list of conditions and the following disclaimer in the
  24. -
  25.  *    documentation and/or other materials provided with the distribution.
  26. -
  27.  *  - Neither the name of Servigistics, Inc. nor the names of
  28. -
  29.  *    its contributors may be used to endorse or promote products derived from
  30. -
  31.  *    this software without specific prior written permission.
  32. -
  33.  *
  34. -
  35.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  36. -
  37.  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  38. -
  39.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  40. -
  41.  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  42. -
  43.  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  44. -
  45.  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  46. -
  47.  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  48. -
  49.  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  50. -
  51.  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  52. -
  53.  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  54. -
  55.  * POSSIBILITY OF SUCH DAMAGE.
  56. -
  57.  *
  58. -
  59.  * @copyright Copyright 2007-2011 Servigistics, Inc. (http://servigistics.com)
  60. -
  61.  * @license http://solr-php-client.googlecode.com/svn/trunk/COPYING New BSD
  62. -
  63.  * @version $Id: ParserException.php 54 2011-02-04 16:29:18Z donovan.jimenez $
  64. -
  65.  *
  66. -
  67.  * @package Apache
  68. -
  69.  * @subpackage Solr
  70. -
  71.  * @author Donovan Jimenez <djimenez@conduit-it.com>
  72. -
  73.  */
  74. -
  75.  
  76. -
  77. -
  78. {
  79. -
  80.     /**
  81. -
  82.      * SVN Revision meta data for this class
  83. -
  84.      */
  85. -
  86.     const SVN_REVISION = '$Revision: 54 $';
  87. -
  88.  
  89. -
  90.     /**
  91. -
  92.      * SVN ID meta data for this class
  93. -
  94.      */
  95. -
  96.     const SVN_ID = '$Id: ParserException.php 54 2011-02-04 16:29:18Z donovan.jimenez $';
  97. -
  98. }
  99. -
-
-

- Documentation generated on Wed, 04 May 2011 11:01:15 -0400 by phpDocumentor 1.4.3 -

- - \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_Response.php.html b/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_Response.php.html deleted file mode 100644 index 9ec73786..00000000 --- a/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_Response.php.html +++ /dev/null @@ -1,267 +0,0 @@ - - - - - - File Source for Response.php - - - - -

Source for file Response.php

-

Documentation is available at Response.php

-
-
  1. <?php
  2. -
  3. /**
  4. -
  5.  * Copyright (c) 2007-2011, Servigistics, Inc.
  6. -
  7.  * All rights reserved.
  8. -
  9.  *
  10. -
  11.  * Redistribution and use in source and binary forms, with or without
  12. -
  13.  * modification, are permitted provided that the following conditions are met:
  14. -
  15.  *
  16. -
  17.  *  - Redistributions of source code must retain the above copyright notice,
  18. -
  19.  *    this list of conditions and the following disclaimer.
  20. -
  21.  *  - Redistributions in binary form must reproduce the above copyright
  22. -
  23.  *    notice, this list of conditions and the following disclaimer in the
  24. -
  25.  *    documentation and/or other materials provided with the distribution.
  26. -
  27.  *  - Neither the name of Servigistics, Inc. nor the names of
  28. -
  29.  *    its contributors may be used to endorse or promote products derived from
  30. -
  31.  *    this software without specific prior written permission.
  32. -
  33.  *
  34. -
  35.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  36. -
  37.  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  38. -
  39.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  40. -
  41.  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  42. -
  43.  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  44. -
  45.  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  46. -
  47.  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  48. -
  49.  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  50. -
  51.  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  52. -
  53.  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  54. -
  55.  * POSSIBILITY OF SUCH DAMAGE.
  56. -
  57.  *
  58. -
  59.  * @copyright Copyright 2007-2011 Servigistics, Inc. (http://servigistics.com)
  60. -
  61.  * @license http://solr-php-client.googlecode.com/svn/trunk/COPYING New BSD
  62. -
  63.  * @version $Id: Response.php 54 2011-02-04 16:29:18Z donovan.jimenez $
  64. -
  65.  *
  66. -
  67.  * @package Apache
  68. -
  69.  * @subpackage Solr
  70. -
  71.  * @author Donovan Jimenez <djimenez@conduit-it.com>
  72. -
  73.  */
  74. -
  75.  
  76. -
  77. require_once(dirname(__FILE__'/ParserException.php');
  78. -
  79.  
  80. -
  81. /**
  82. -
  83.  * Represents a Solr response.  Parses the raw response into a set of stdClass objects
  84. -
  85.  * and associative arrays for easy access.
  86. -
  87.  *
  88. -
  89.  * Currently requires json_decode which is bundled with PHP >= 5.2.0, Alternatively can be
  90. -
  91.  * installed with PECL.  Zend Framework also includes a purely PHP solution.
  92. -
  93.  */
  94. -
  95. -
  96. {
  97. -
  98.     /**
  99. -
  100.      * SVN Revision meta data for this class
  101. -
  102.      */
  103. -
  104.     const SVN_REVISION '$Revision: 54 $';
  105. -
  106.  
  107. -
  108.     /**
  109. -
  110.      * SVN ID meta data for this class
  111. -
  112.      */
  113. -
  114.     const SVN_ID '$Id: Response.php 54 2011-02-04 16:29:18Z donovan.jimenez $';
  115. -
  116.  
  117. -
  118.     /**
  119. -
  120.      * Holds the raw response used in construction
  121. -
  122.      *
  123. -
  124.      * @var Apache_Solr_HttpTransport_Response HTTP response
  125. -
  126.      */
  127. -
  128.     protected $_response;
  129. -
  130.  
  131. -
  132.     /**
  133. -
  134.      * Whether the raw response has been parsed
  135. -
  136.      *
  137. -
  138.      * @var boolean 
  139. -
  140.      */
  141. -
  142.     protected $_isParsed = false;
  143. -
  144.  
  145. -
  146.     /**
  147. -
  148.      * Parsed representation of the data
  149. -
  150.      *
  151. -
  152.      * @var mixed 
  153. -
  154.      */
  155. -
  156.     protected $_parsedData;
  157. -
  158.  
  159. -
  160.     /**
  161. -
  162.      * Data parsing flags.  Determines what extra processing should be done
  163. -
  164.      * after the data is initially converted to a data structure.
  165. -
  166.      *
  167. -
  168.      * @var boolean 
  169. -
  170.      */
  171. -
  172.     protected $_createDocuments = true,
  173. -
  174.             $_collapseSingleValueArrays = true;
  175. -
  176.  
  177. -
  178.     /**
  179. -
  180.      * Constructor. Takes the raw HTTP response body and the exploded HTTP headers
  181. -
  182.      *
  183. -
  184.      * @return Apache_Solr_HttpTransport_Response HTTP response
  185. -
  186.      * @param boolean $createDocuments Whether to convert the documents json_decoded as stdClass instances to Apache_Solr_Document instances
  187. -
  188.      * @param boolean $collapseSingleValueArrays Whether to make multivalued fields appear as single values
  189. -
  190.      */
  191. -
  192.     public function __construct(Apache_Solr_HttpTransport_Response $response$createDocuments true$collapseSingleValueArrays true)
  193. -
  194.     {
  195. -
  196.         $this->_response = $response;
  197. -
  198.         $this->_createDocuments = (bool) $createDocuments;
  199. -
  200.         $this->_collapseSingleValueArrays = (bool) $collapseSingleValueArrays;
  201. -
  202.     }
  203. -
  204.  
  205. -
  206.     /**
  207. -
  208.      * Get the HTTP status code
  209. -
  210.      *
  211. -
  212.      * @return integer 
  213. -
  214.      */
  215. -
  216.     public function getHttpStatus()
  217. -
  218.     {
  219. -
  220.         return $this->_response->getStatusCode();
  221. -
  222.     }
  223. -
  224.  
  225. -
  226.     /**
  227. -
  228.      * Get the HTTP status message of the response
  229. -
  230.      *
  231. -
  232.      * @return string 
  233. -
  234.      */
  235. -
  236.     public function getHttpStatusMessage()
  237. -
  238.     {
  239. -
  240.         return $this->_response->getStatusMessage();
  241. -
  242.     }
  243. -
  244.  
  245. -
  246.     /**
  247. -
  248.      * Get content type of this Solr response
  249. -
  250.      *
  251. -
  252.      * @return string 
  253. -
  254.      */
  255. -
  256.     public function getType()
  257. -
  258.     {
  259. -
  260.         return $this->_response->getMimeType();
  261. -
  262.     }
  263. -
  264.  
  265. -
  266.     /**
  267. -
  268.      * Get character encoding of this response. Should usually be utf-8, but just in case
  269. -
  270.      *
  271. -
  272.      * @return string 
  273. -
  274.      */
  275. -
  276.     public function getEncoding()
  277. -
  278.     {
  279. -
  280.         return $this->_response->getEncoding();
  281. -
  282.     }
  283. -
  284.  
  285. -
  286.     /**
  287. -
  288.      * Get the raw response as it was given to this object
  289. -
  290.      *
  291. -
  292.      * @return string 
  293. -
  294.      */
  295. -
  296.     public function getRawResponse()
  297. -
  298.     {
  299. -
  300.         return $this->_response->getBody();
  301. -
  302.     }
  303. -
  304.  
  305. -
  306.     /**
  307. -
  308.      * Magic get to expose the parsed data and to lazily load it
  309. -
  310.      *
  311. -
  312.      * @param string $key 
  313. -
  314.      * @return mixed 
  315. -
  316.      */
  317. -
  318.     public function __get($key)
  319. -
  320.     {
  321. -
  322.         if (!$this->_isParsed)
  323. -
  324.         {
  325. -
  326.             $this->_parseData();
  327. -
  328.             $this->_isParsed = true;
  329. -
  330.         }
  331. -
  332.  
  333. -
  334.         if (isset($this->_parsedData->$key))
  335. -
  336.         {
  337. -
  338.             return $this->_parsedData->$key;
  339. -
  340.         }
  341. -
  342.  
  343. -
  344.         return null;
  345. -
  346.     }
  347. -
  348.  
  349. -
  350.     /**
  351. -
  352.      * Magic function for isset function on parsed data
  353. -
  354.      *
  355. -
  356.      * @param string $key 
  357. -
  358.      * @return boolean 
  359. -
  360.      */
  361. -
  362.     public function __isset($key)
  363. -
  364.     {
  365. -
  366.         if (!$this->_isParsed)
  367. -
  368.         {
  369. -
  370.             $this->_parseData();
  371. -
  372.             $this->_isParsed = true;
  373. -
  374.         }
  375. -
  376.  
  377. -
  378.         return isset($this->_parsedData->$key);
  379. -
  380.     }
  381. -
  382.  
  383. -
  384.     /**
  385. -
  386.      * Parse the raw response into the parsed_data array for access
  387. -
  388.      *
  389. -
  390.      * @throws Apache_Solr_ParserException If the data could not be parsed
  391. -
  392.      */
  393. -
  394.     protected function _parseData()
  395. -
  396.     {
  397. -
  398.         //An alternative would be to use Zend_Json::decode(...)
  399. -
  400.         $data json_decode($this->_response->getBody());
  401. -
  402.  
  403. -
  404.         // check that we receive a valid JSON response - we should never receive a null
  405. -
  406.         if ($data === null)
  407. -
  408.         {
  409. -
  410.             throw new Apache_Solr_ParserException('Solr response does not appear to be valid JSON, please examine the raw response with getRawResponse() method');
  411. -
  412.         }
  413. -
  414.  
  415. -
  416.         //if we're configured to collapse single valued arrays or to convert them to Apache_Solr_Document objects
  417. -
  418.         //and we have response documents, then try to collapse the values and / or convert them now
  419. -
  420.         if (($this->_createDocuments || $this->_collapseSingleValueArrays&& isset($data->response&& is_array($data->response->docs))
  421. -
  422.         {
  423. -
  424.             $documents array();
  425. -
  426.  
  427. -
  428.             foreach ($data->response->docs as $originalDocument)
  429. -
  430.             {
  431. -
  432.                 if ($this->_createDocuments)
  433. -
  434.                 {
  435. -
  436.                     $document new Apache_Solr_Document();
  437. -
  438.                 }
  439. -
  440.                 else
  441. -
  442.                 {
  443. -
  444.                     $document $originalDocument;
  445. -
  446.                 }
  447. -
  448.  
  449. -
  450.                 foreach ($originalDocument as $key => $value)
  451. -
  452.                 {
  453. -
  454.                     //If a result is an array with only a single
  455. -
  456.                     //value then its nice to be able to access
  457. -
  458.                     //it as if it were always a single value
  459. -
  460.                     if ($this->_collapseSingleValueArrays && is_array($value&& count($value<= 1)
  461. -
  462.                     {
  463. -
  464.                         $value array_shift($value);
  465. -
  466.                     }
  467. -
  468.  
  469. -
  470.                     $document->$key $value;
  471. -
  472.                 }
  473. -
  474.  
  475. -
  476.                 $documents[$document;
  477. -
  478.             }
  479. -
  480.  
  481. -
  482.             $data->response->docs $documents;
  483. -
  484.         }
  485. -
  486.  
  487. -
  488.         $this->_parsedData = $data;
  489. -
  490.     }
  491. -
  492. }
  493. -
-
-

- Documentation generated on Wed, 04 May 2011 11:01:15 -0400 by phpDocumentor 1.4.3 -

- - \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_Service.php.html b/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_Service.php.html deleted file mode 100644 index 9f1a4388..00000000 --- a/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_Service.php.html +++ /dev/null @@ -1,1201 +0,0 @@ - - - - - - File Source for Service.php - - - - -

Source for file Service.php

-

Documentation is available at Service.php

-
-
  1. <?php
  2. -
  3. /**
  4. -
  5.  * Copyright (c) 2007-2011, Servigistics, Inc.
  6. -
  7.  * All rights reserved.
  8. -
  9.  *
  10. -
  11.  * Redistribution and use in source and binary forms, with or without
  12. -
  13.  * modification, are permitted provided that the following conditions are met:
  14. -
  15.  *
  16. -
  17.  *  - Redistributions of source code must retain the above copyright notice,
  18. -
  19.  *    this list of conditions and the following disclaimer.
  20. -
  21.  *  - Redistributions in binary form must reproduce the above copyright
  22. -
  23.  *    notice, this list of conditions and the following disclaimer in the
  24. -
  25.  *    documentation and/or other materials provided with the distribution.
  26. -
  27.  *  - Neither the name of Servigistics, Inc. nor the names of
  28. -
  29.  *    its contributors may be used to endorse or promote products derived from
  30. -
  31.  *    this software without specific prior written permission.
  32. -
  33.  *
  34. -
  35.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  36. -
  37.  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  38. -
  39.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  40. -
  41.  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  42. -
  43.  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  44. -
  45.  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  46. -
  47.  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  48. -
  49.  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  50. -
  51.  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  52. -
  53.  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  54. -
  55.  * POSSIBILITY OF SUCH DAMAGE.
  56. -
  57.  *
  58. -
  59.  * @copyright Copyright 2007-2011 Servigistics, Inc. (http://servigistics.com)
  60. -
  61.  * @license http://solr-php-client.googlecode.com/svn/trunk/COPYING New BSD
  62. -
  63.  * @version $Id: Service.php 59 2011-02-08 20:38:59Z donovan.jimenez $
  64. -
  65.  *
  66. -
  67.  * @package Apache
  68. -
  69.  * @subpackage Solr
  70. -
  71.  * @author Donovan Jimenez <djimenez@conduit-it.com>
  72. -
  73.  */
  74. -
  75.  
  76. -
  77. // See Issue #1 (http://code.google.com/p/solr-php-client/issues/detail?id=1)
  78. -
  79. // Doesn't follow typical include path conventions, but is more convenient for users
  80. -
  81. require_once(dirname(__FILE__'/Exception.php');
  82. -
  83. require_once(dirname(__FILE__'/HttpTransportException.php');
  84. -
  85. require_once(dirname(__FILE__'/InvalidArgumentException.php');
  86. -
  87.  
  88. -
  89. require_once(dirname(__FILE__'/Document.php');
  90. -
  91. require_once(dirname(__FILE__'/Response.php');
  92. -
  93.  
  94. -
  95. require_once(dirname(__FILE__'/HttpTransport/Interface.php');
  96. -
  97.  
  98. -
  99. /**
  100. -
  101.  * Starting point for the Solr API. Represents a Solr server resource and has
  102. -
  103.  * methods for pinging, adding, deleting, committing, optimizing and searching.
  104. -
  105.  *
  106. -
  107.  * Example Usage:
  108. -
  109.  * <code>
  110. -
  111.  * ...
  112. -
  113.  * $solr = new Apache_Solr_Service(); //or explicitly new Apache_Solr_Service('localhost', 8180, '/solr')
  114. -
  115.  *
  116. -
  117.  * if ($solr->ping())
  118. -
  119.  * {
  120. -
  121.  *         $solr->deleteByQuery('*:*'); //deletes ALL documents - be careful :)
  122. -
  123.  *
  124. -
  125.  *         $document = new Apache_Solr_Document();
  126. -
  127.  *         $document->id = uniqid(); //or something else suitably unique
  128. -
  129.  *
  130. -
  131.  *         $document->title = 'Some Title';
  132. -
  133.  *         $document->content = 'Some content for this wonderful document. Blah blah blah.';
  134. -
  135.  *
  136. -
  137.  *         $solr->addDocument($document);     //if you're going to be adding documents in bulk using addDocuments
  138. -
  139.  *                                         //with an array of documents is faster
  140. -
  141.  *
  142. -
  143.  *         $solr->commit(); //commit to see the deletes and the document
  144. -
  145.  *         $solr->optimize(); //merges multiple segments into one
  146. -
  147.  *
  148. -
  149.  *         //and the one we all care about, search!
  150. -
  151.  *         //any other common or custom parameters to the request handler can go in the
  152. -
  153.  *         //optional 4th array argument.
  154. -
  155.  *         $solr->search('content:blah', 0, 10, array('sort' => 'timestamp desc'));
  156. -
  157.  * }
  158. -
  159.  * ...
  160. -
  161.  * </code>
  162. -
  163.  *
  164. -
  165.  * @todo Investigate using other HTTP clients other than file_get_contents built-in handler. Could provide performance
  166. -
  167.  *  improvements when dealing with multiple requests by using HTTP's keep alive functionality
  168. -
  169.  */
  170. -
  171. -
  172. {
  173. -
  174.     /**
  175. -
  176.      * SVN Revision meta data for this class
  177. -
  178.      */
  179. -
  180.     const SVN_REVISION '$Revision: 59 $';
  181. -
  182.  
  183. -
  184.     /**
  185. -
  186.      * SVN ID meta data for this class
  187. -
  188.      */
  189. -
  190.     const SVN_ID '$Id: Service.php 59 2011-02-08 20:38:59Z donovan.jimenez $';
  191. -
  192.  
  193. -
  194.     /**
  195. -
  196.      * Response writer we'll request - JSON. See http://code.google.com/p/solr-php-client/issues/detail?id=6#c1 for reasoning
  197. -
  198.      */
  199. -
  200.     const SOLR_WRITER 'json';
  201. -
  202.  
  203. -
  204.     /**
  205. -
  206.      * NamedList Treatment constants
  207. -
  208.      */
  209. -
  210.     const NAMED_LIST_FLAT 'flat';
  211. -
  212.     const NAMED_LIST_MAP 'map';
  213. -
  214.  
  215. -
  216.     /**
  217. -
  218.      * Search HTTP Methods
  219. -
  220.      */
  221. -
  222.     const METHOD_GET 'GET';
  223. -
  224.     const METHOD_POST 'POST';
  225. -
  226.  
  227. -
  228.     /**
  229. -
  230.      * Servlet mappings
  231. -
  232.      */
  233. -
  234.     const PING_SERVLET 'admin/ping';
  235. -
  236.     const UPDATE_SERVLET 'update';
  237. -
  238.     const SEARCH_SERVLET 'select';
  239. -
  240.     const THREADS_SERVLET 'admin/threads';
  241. -
  242.     const EXTRACT_SERVLET 'update/extract';
  243. -
  244.  
  245. -
  246.     /**
  247. -
  248.      * Server identification strings
  249. -
  250.      *
  251. -
  252.      * @var string 
  253. -
  254.      */
  255. -
  256.     protected $_host$_port$_path;
  257. -
  258.  
  259. -
  260.     /**
  261. -
  262.      * Whether {@link Apache_Solr_Response} objects should create {@link Apache_Solr_Document}s in
  263. -
  264.      * the returned parsed data
  265. -
  266.      *
  267. -
  268.      * @var boolean 
  269. -
  270.      */
  271. -
  272.     protected $_createDocuments = true;
  273. -
  274.  
  275. -
  276.     /**
  277. -
  278.      * Whether {@link Apache_Solr_Response} objects should have multivalue fields with only a single value
  279. -
  280.      * collapsed to appear as a single value would.
  281. -
  282.      *
  283. -
  284.      * @var boolean 
  285. -
  286.      */
  287. -
  288.     protected $_collapseSingleValueArrays = true;
  289. -
  290.  
  291. -
  292.     /**
  293. -
  294.      * How NamedLists should be formatted in the output.  This specifically effects facet counts. Valid values
  295. -
  296.      * are {@link Apache_Solr_Service::NAMED_LIST_MAP} (default) or {@link Apache_Solr_Service::NAMED_LIST_FLAT}.
  297. -
  298.      *
  299. -
  300.      * @var string 
  301. -
  302.      */
  303. -
  304.     protected $_namedListTreatment = self::NAMED_LIST_MAP;
  305. -
  306.  
  307. -
  308.     /**
  309. -
  310.      * Query delimiters. Someone might want to be able to change
  311. -
  312.      * these (to use &amp; instead of & for example), so I've provided them.
  313. -
  314.      *
  315. -
  316.      * @var string 
  317. -
  318.      */
  319. -
  320.     protected $_queryDelimiter = '?'$_queryStringDelimiter = '&'$_queryBracketsEscaped = true;
  321. -
  322.  
  323. -
  324.     /**
  325. -
  326.      * Constructed servlet full path URLs
  327. -
  328.      *
  329. -
  330.      * @var string 
  331. -
  332.      */
  333. -
  334.     protected $_pingUrl$_updateUrl$_searchUrl$_threadsUrl;
  335. -
  336.  
  337. -
  338.     /**
  339. -
  340.      * Keep track of whether our URLs have been constructed
  341. -
  342.      *
  343. -
  344.      * @var boolean 
  345. -
  346.      */
  347. -
  348.     protected $_urlsInited = false;
  349. -
  350.  
  351. -
  352.     /**
  353. -
  354.      * HTTP Transport implementation (pluggable)
  355. -
  356.      *
  357. -
  358.      * @var Apache_Solr_HttpTransport_Interface 
  359. -
  360.      */
  361. -
  362.     protected $_httpTransport = false;
  363. -
  364.  
  365. -
  366.     /**
  367. -
  368.      * Escape a value for special query characters such as ':', '(', ')', '*', '?', etc.
  369. -
  370.      *
  371. -
  372.      * NOTE: inside a phrase fewer characters need escaped, use {@link Apache_Solr_Service::escapePhrase()} instead
  373. -
  374.      *
  375. -
  376.      * @param string $value 
  377. -
  378.      * @return string 
  379. -
  380.      */
  381. -
  382.     static public function escape($value)
  383. -
  384.     {
  385. -
  386.         //list taken from http://lucene.apache.org/java/docs/queryparsersyntax.html#Escaping%20Special%20Characters
  387. -
  388.         $pattern '/(\+|-|&&|\|\||!|\(|\)|\{|}|\[|]|\^|"|~|\*|\?|:|\\\)/';
  389. -
  390.         $replace '\\\$1';
  391. -
  392.  
  393. -
  394.         return preg_replace($pattern$replace$value);
  395. -
  396.     }
  397. -
  398.  
  399. -
  400.     /**
  401. -
  402.      * Escape a value meant to be contained in a phrase for special query characters
  403. -
  404.      *
  405. -
  406.      * @param string $value 
  407. -
  408.      * @return string 
  409. -
  410.      */
  411. -
  412.     static public function escapePhrase($value)
  413. -
  414.     {
  415. -
  416.         $pattern '/("|\\\)/';
  417. -
  418.         $replace '\\\$1';
  419. -
  420.  
  421. -
  422.         return preg_replace($pattern$replace$value);
  423. -
  424.     }
  425. -
  426.  
  427. -
  428.     /**
  429. -
  430.      * Convenience function for creating phrase syntax from a value
  431. -
  432.      *
  433. -
  434.      * @param string $value 
  435. -
  436.      * @return string 
  437. -
  438.      */
  439. -
  440.     static public function phrase($value)
  441. -
  442.     {
  443. -
  444.         return '"' self::escapePhrase($value'"';
  445. -
  446.     }
  447. -
  448.  
  449. -
  450.     /**
  451. -
  452.      * Constructor. All parameters are optional and will take on default values
  453. -
  454.      * if not specified.
  455. -
  456.      *
  457. -
  458.      * @param string $host 
  459. -
  460.      * @param string $port 
  461. -
  462.      * @param string $path 
  463. -
  464.      * @param Apache_Solr_HttpTransport_Interface $httpTransport 
  465. -
  466.      */
  467. -
  468.     public function __construct($host 'localhost'$port 8180$path '/solr/'$httpTransport false)
  469. -
  470.     {
  471. -
  472.         $this->setHost($host);
  473. -
  474.         $this->setPort($port);
  475. -
  476.         $this->setPath($path);
  477. -
  478.  
  479. -
  480.         $this->_initUrls();
  481. -
  482.  
  483. -
  484.         if ($httpTransport)
  485. -
  486.         {
  487. -
  488.             $this->setHttpTransport($httpTransport);
  489. -
  490.         }
  491. -
  492.  
  493. -
  494.         // check that our php version is >= 5.1.3 so we can correct for http_build_query behavior later
  495. -
  496.         $this->_queryBracketsEscaped = version_compare(phpversion()'5.1.3''>=');
  497. -
  498.     }
  499. -
  500.  
  501. -
  502.     /**
  503. -
  504.      * Return a valid http URL given this server's host, port and path and a provided servlet name
  505. -
  506.      *
  507. -
  508.      * @param string $servlet 
  509. -
  510.      * @return string 
  511. -
  512.      */
  513. -
  514.     protected function _constructUrl($servlet$params array())
  515. -
  516.     {
  517. -
  518.         if (count($params))
  519. -
  520.         {
  521. -
  522.             //escape all parameters appropriately for inclusion in the query string
  523. -
  524.             $escapedParams array();
  525. -
  526.  
  527. -
  528.             foreach ($params as $key => $value)
  529. -
  530.             {
  531. -
  532.                 $escapedParams[urlencode($key'=' urlencode($value);
  533. -
  534.             }
  535. -
  536.  
  537. -
  538.             $queryString $this->_queryDelimiter . implode($this->_queryStringDelimiter$escapedParams);
  539. -
  540.         }
  541. -
  542.         else
  543. -
  544.         {
  545. -
  546.             $queryString '';
  547. -
  548.         }
  549. -
  550.  
  551. -
  552.         return 'http://' $this->_host . ':' $this->_port . $this->_path . $servlet $queryString;
  553. -
  554.     }
  555. -
  556.  
  557. -
  558.     /**
  559. -
  560.      * Construct the Full URLs for the three servlets we reference
  561. -
  562.      */
  563. -
  564.     protected function _initUrls()
  565. -
  566.     {
  567. -
  568.         //Initialize our full servlet URLs now that we have server information
  569. -
  570.         $this->_extractUrl $this->_constructUrl(self::EXTRACT_SERVLET);
  571. -
  572.         $this->_pingUrl = $this->_constructUrl(self::PING_SERVLET);
  573. -
  574.         $this->_searchUrl = $this->_constructUrl(self::SEARCH_SERVLET);
  575. -
  576.         $this->_threadsUrl = $this->_constructUrl(self::THREADS_SERVLETarray('wt' => self::SOLR_WRITER ));
  577. -
  578.         $this->_updateUrl = $this->_constructUrl(self::UPDATE_SERVLETarray('wt' => self::SOLR_WRITER ));
  579. -
  580.  
  581. -
  582.         $this->_urlsInited = true;
  583. -
  584.     }
  585. -
  586.  
  587. -
  588.     protected function _generateQueryString($params)
  589. -
  590.     {
  591. -
  592.         // use http_build_query to encode our arguments because its faster
  593. -
  594.         // than urlencoding all the parts ourselves in a loop
  595. -
  596.         //
  597. -
  598.         // because http_build_query treats arrays differently than we want to, correct the query
  599. -
  600.         // string by changing foo[#]=bar (# being an actual number) parameter strings to just
  601. -
  602.         // multiple foo=bar strings. This regex should always work since '=' will be urlencoded
  603. -
  604.         // anywhere else the regex isn't expecting it
  605. -
  606.         //
  607. -
  608.         // NOTE: before php 5.1.3 brackets were not url encoded by http_build query - we've checked
  609. -
  610.         // the php version in the constructor and put the results in the instance variable. Also, before
  611. -
  612.         // 5.1.2 the arg_separator parameter was not available, so don't use it
  613. -
  614.         if ($this->_queryBracketsEscaped)
  615. -
  616.         {
  617. -
  618.             $queryString http_build_query($paramsnull$this->_queryStringDelimiter);
  619. -
  620.             return preg_replace('/%5B(?:[0-9]|[1-9][0-9]+)%5D=/''='$queryString);
  621. -
  622.         }
  623. -
  624.         else
  625. -
  626.         {
  627. -
  628.             $queryString http_build_query($params);
  629. -
  630.             return preg_replace('/\\[(?:[0-9]|[1-9][0-9]+)\\]=/''='$queryString);
  631. -
  632.         }
  633. -
  634.     }
  635. -
  636.  
  637. -
  638.     /**
  639. -
  640.      * Central method for making a get operation against this Solr Server
  641. -
  642.      *
  643. -
  644.      * @param string $url 
  645. -
  646.      * @param float $timeout Read timeout in seconds
  647. -
  648.      * @return Apache_Solr_Response 
  649. -
  650.      *
  651. -
  652.      * @throws Apache_Solr_HttpTransportException If a non 200 response status is returned
  653. -
  654.      */
  655. -
  656.     protected function _sendRawGet($url$timeout FALSE)
  657. -
  658.     {
  659. -
  660.         $httpTransport $this->getHttpTransport();
  661. -
  662.  
  663. -
  664.         $httpResponse $httpTransport->performGetRequest($url$timeout);
  665. -
  666.         $solrResponse new Apache_Solr_Response($httpResponse$this->_createDocuments$this->_collapseSingleValueArrays);
  667. -
  668.  
  669. -
  670.         if ($solrResponse->getHttpStatus(!= 200)
  671. -
  672.         {
  673. -
  674.             throw new Apache_Solr_HttpTransportException($solrResponse);
  675. -
  676.         }
  677. -
  678.  
  679. -
  680.         return $solrResponse;
  681. -
  682.     }
  683. -
  684.  
  685. -
  686.     /**
  687. -
  688.      * Central method for making a post operation against this Solr Server
  689. -
  690.      *
  691. -
  692.      * @param string $url 
  693. -
  694.      * @param string $rawPost 
  695. -
  696.      * @param float $timeout Read timeout in seconds
  697. -
  698.      * @param string $contentType 
  699. -
  700.      * @return Apache_Solr_Response 
  701. -
  702.      *
  703. -
  704.      * @throws Apache_Solr_HttpTransportException If a non 200 response status is returned
  705. -
  706.      */
  707. -
  708.     protected function _sendRawPost($url$rawPost$timeout FALSE$contentType 'text/xml; charset=UTF-8')
  709. -
  710.     {
  711. -
  712.         $httpTransport $this->getHttpTransport();
  713. -
  714.  
  715. -
  716.         $httpResponse $httpTransport->performPostRequest($url$rawPost$contentType$timeout);
  717. -
  718.         $solrResponse new Apache_Solr_Response($httpResponse$this->_createDocuments$this->_collapseSingleValueArrays);
  719. -
  720.  
  721. -
  722.         if ($solrResponse->getHttpStatus(!= 200)
  723. -
  724.         {
  725. -
  726.             throw new Apache_Solr_HttpTransportException($solrResponse);
  727. -
  728.         }
  729. -
  730.  
  731. -
  732.         return $solrResponse;
  733. -
  734.     }
  735. -
  736.  
  737. -
  738.     /**
  739. -
  740.      * Returns the set host
  741. -
  742.      *
  743. -
  744.      * @return string 
  745. -
  746.      */
  747. -
  748.     public function getHost()
  749. -
  750.     {
  751. -
  752.         return $this->_host;
  753. -
  754.     }
  755. -
  756.  
  757. -
  758.     /**
  759. -
  760.      * Set the host used. If empty will fallback to constants
  761. -
  762.      *
  763. -
  764.      * @param string $host 
  765. -
  766.      *
  767. -
  768.      * @throws Apache_Solr_InvalidArgumentException If the host parameter is empty
  769. -
  770.      */
  771. -
  772.     public function setHost($host)
  773. -
  774.     {
  775. -
  776.         //Use the provided host or use the default
  777. -
  778.         if (empty($host))
  779. -
  780.         {
  781. -
  782.             throw new Apache_Solr_InvalidArgumentException('Host parameter is empty');
  783. -
  784.         }
  785. -
  786.         else
  787. -
  788.         {
  789. -
  790.             $this->_host = $host;
  791. -
  792.         }
  793. -
  794.  
  795. -
  796.         if ($this->_urlsInited)
  797. -
  798.         {
  799. -
  800.             $this->_initUrls();
  801. -
  802.         }
  803. -
  804.     }
  805. -
  806.  
  807. -
  808.     /**
  809. -
  810.      * Get the set port
  811. -
  812.      *
  813. -
  814.      * @return integer 
  815. -
  816.      */
  817. -
  818.     public function getPort()
  819. -
  820.     {
  821. -
  822.         return $this->_port;
  823. -
  824.     }
  825. -
  826.  
  827. -
  828.     /**
  829. -
  830.      * Set the port used. If empty will fallback to constants
  831. -
  832.      *
  833. -
  834.      * @param integer $port 
  835. -
  836.      *
  837. -
  838.      * @throws Apache_Solr_InvalidArgumentException If the port parameter is empty
  839. -
  840.      */
  841. -
  842.     public function setPort($port)
  843. -
  844.     {
  845. -
  846.         //Use the provided port or use the default
  847. -
  848.         $port = (int) $port;
  849. -
  850.  
  851. -
  852.         if ($port <= 0)
  853. -
  854.         {
  855. -
  856.             throw new Apache_Solr_InvalidArgumentException('Port is not a valid port number');
  857. -
  858.         }
  859. -
  860.         else
  861. -
  862.         {
  863. -
  864.             $this->_port = $port;
  865. -
  866.         }
  867. -
  868.  
  869. -
  870.         if ($this->_urlsInited)
  871. -
  872.         {
  873. -
  874.             $this->_initUrls();
  875. -
  876.         }
  877. -
  878.     }
  879. -
  880.  
  881. -
  882.     /**
  883. -
  884.      * Get the set path.
  885. -
  886.      *
  887. -
  888.      * @return string 
  889. -
  890.      */
  891. -
  892.     public function getPath()
  893. -
  894.     {
  895. -
  896.         return $this->_path;
  897. -
  898.     }
  899. -
  900.  
  901. -
  902.     /**
  903. -
  904.      * Set the path used. If empty will fallback to constants
  905. -
  906.      *
  907. -
  908.      * @param string $path 
  909. -
  910.      */
  911. -
  912.     public function setPath($path)
  913. -
  914.     {
  915. -
  916.         $path trim($path'/');
  917. -
  918.  
  919. -
  920.         $this->_path = '/' $path '/';
  921. -
  922.  
  923. -
  924.         if ($this->_urlsInited)
  925. -
  926.         {
  927. -
  928.             $this->_initUrls();
  929. -
  930.         }
  931. -
  932.     }
  933. -
  934.  
  935. -
  936.     /**
  937. -
  938.      * Get the current configured HTTP Transport
  939. -
  940.      *
  941. -
  942.      * @return HttpTransportInterface 
  943. -
  944.      */
  945. -
  946.     public function getHttpTransport()
  947. -
  948.     {
  949. -
  950.         // lazy load a default if one has not be set
  951. -
  952.         if ($this->_httpTransport === false)
  953. -
  954.         {
  955. -
  956.             require_once(dirname(__FILE__'/HttpTransport/FileGetContents.php');
  957. -
  958.  
  959. -
  960.             $this->_httpTransport = new Apache_Solr_HttpTransport_FileGetContents();
  961. -
  962.         }
  963. -
  964.  
  965. -
  966.         return $this->_httpTransport;
  967. -
  968.     }
  969. -
  970.  
  971. -
  972.     /**
  973. -
  974.      * Set the HTTP Transport implemenation that will be used for all HTTP requests
  975. -
  976.      *
  977. -
  978.      * @param Apache_Solr_HttpTransport_Interface 
  979. -
  980.      */
  981. -
  982.     public function setHttpTransport(Apache_Solr_HttpTransport_Interface $httpTransport)
  983. -
  984.     {
  985. -
  986.         $this->_httpTransport = $httpTransport;
  987. -
  988.     }
  989. -
  990.  
  991. -
  992.     /**
  993. -
  994.      * Set the create documents flag. This determines whether {@link Apache_Solr_Response} objects will
  995. -
  996.      * parse the response and create {@link Apache_Solr_Document} instances in place.
  997. -
  998.      *
  999. -
  1000.      * @param boolean $createDocuments 
  1001. -
  1002.      */
  1003. -
  1004.     public function setCreateDocuments($createDocuments)
  1005. -
  1006.     {
  1007. -
  1008.         $this->_createDocuments = (bool) $createDocuments;
  1009. -
  1010.     }
  1011. -
  1012.  
  1013. -
  1014.     /**
  1015. -
  1016.      * Get the current state of teh create documents flag.
  1017. -
  1018.      *
  1019. -
  1020.      * @return boolean 
  1021. -
  1022.      */
  1023. -
  1024.     public function getCreateDocuments()
  1025. -
  1026.     {
  1027. -
  1028.         return $this->_createDocuments;
  1029. -
  1030.     }
  1031. -
  1032.  
  1033. -
  1034.     /**
  1035. -
  1036.      * Set the collapse single value arrays flag.
  1037. -
  1038.      *
  1039. -
  1040.      * @param boolean $collapseSingleValueArrays 
  1041. -
  1042.      */
  1043. -
  1044.     public function setCollapseSingleValueArrays($collapseSingleValueArrays)
  1045. -
  1046.     {
  1047. -
  1048.         $this->_collapseSingleValueArrays = (bool) $collapseSingleValueArrays;
  1049. -
  1050.     }
  1051. -
  1052.  
  1053. -
  1054.     /**
  1055. -
  1056.      * Get the current state of the collapse single value arrays flag.
  1057. -
  1058.      *
  1059. -
  1060.      * @return boolean 
  1061. -
  1062.      */
  1063. -
  1064.     public function getCollapseSingleValueArrays()
  1065. -
  1066.     {
  1067. -
  1068.         return $this->_collapseSingleValueArrays;
  1069. -
  1070.     }
  1071. -
  1072.  
  1073. -
  1074.     /**
  1075. -
  1076.      * Get the current default timeout setting (initially the default_socket_timeout ini setting)
  1077. -
  1078.      * in seconds
  1079. -
  1080.      *
  1081. -
  1082.      * @return float 
  1083. -
  1084.      *
  1085. -
  1086.      * @deprecated Use the getDefaultTimeout method on the HTTP transport implementation
  1087. -
  1088.      */
  1089. -
  1090.     public function getDefaultTimeout()
  1091. -
  1092.     {
  1093. -
  1094.         return $this->getHttpTransport()->getDefaultTimeout();
  1095. -
  1096.     }
  1097. -
  1098.  
  1099. -
  1100.     /**
  1101. -
  1102.      * Set the default timeout for all calls that aren't passed a specific timeout
  1103. -
  1104.      *
  1105. -
  1106.      * @param float $timeout Timeout value in seconds
  1107. -
  1108.      *
  1109. -
  1110.      * @deprecated Use the setDefaultTimeout method on the HTTP transport implementation
  1111. -
  1112.      */
  1113. -
  1114.     public function setDefaultTimeout($timeout)
  1115. -
  1116.     {
  1117. -
  1118.         $this->getHttpTransport()->setDefaultTimeout($timeout);
  1119. -
  1120.     }
  1121. -
  1122.  
  1123. -
  1124.     /**
  1125. -
  1126.      * Set how NamedLists should be formatted in the response data. This mainly effects
  1127. -
  1128.      * the facet counts format.
  1129. -
  1130.      *
  1131. -
  1132.      * @param string $namedListTreatment 
  1133. -
  1134.      * @throws Apache_Solr_InvalidArgumentException If invalid option is set
  1135. -
  1136.      */
  1137. -
  1138.     public function setNamedListTreatment($namedListTreatment)
  1139. -
  1140.     {
  1141. -
  1142.         switch ((string) $namedListTreatment)
  1143. -
  1144.         {
  1145. -
  1146.             case Apache_Solr_Service::NAMED_LIST_FLAT:
  1147. -
  1148.                 $this->_namedListTreatment = Apache_Solr_Service::NAMED_LIST_FLAT;
  1149. -
  1150.                 break;
  1151. -
  1152.  
  1153. -
  1154.             case Apache_Solr_Service::NAMED_LIST_MAP:
  1155. -
  1156.                 $this->_namedListTreatment = Apache_Solr_Service::NAMED_LIST_MAP;
  1157. -
  1158.                 break;
  1159. -
  1160.  
  1161. -
  1162.             default:
  1163. -
  1164.                 throw new Apache_Solr_InvalidArgumentException('Not a valid named list treatement option');
  1165. -
  1166.         }
  1167. -
  1168.     }
  1169. -
  1170.  
  1171. -
  1172.     /**
  1173. -
  1174.      * Get the current setting for named list treatment.
  1175. -
  1176.      *
  1177. -
  1178.      * @return string 
  1179. -
  1180.      */
  1181. -
  1182.     public function getNamedListTreatment()
  1183. -
  1184.     {
  1185. -
  1186.         return $this->_namedListTreatment;
  1187. -
  1188.     }
  1189. -
  1190.  
  1191. -
  1192.     /**
  1193. -
  1194.      * Set the string used to separate the path form the query string.
  1195. -
  1196.      * Defaulted to '?'
  1197. -
  1198.      *
  1199. -
  1200.      * @param string $queryDelimiter 
  1201. -
  1202.      */
  1203. -
  1204.     public function setQueryDelimiter($queryDelimiter)
  1205. -
  1206.     {
  1207. -
  1208.         $this->_queryDelimiter = $queryDelimiter;
  1209. -
  1210.     }
  1211. -
  1212.  
  1213. -
  1214.     /**
  1215. -
  1216.      * Set the string used to separate the parameters in thequery string
  1217. -
  1218.      * Defaulted to '&'
  1219. -
  1220.      *
  1221. -
  1222.      * @param string $queryStringDelimiter 
  1223. -
  1224.      */
  1225. -
  1226.     public function setQueryStringDelimiter($queryStringDelimiter)
  1227. -
  1228.     {
  1229. -
  1230.         $this->_queryStringDelimiter = $queryStringDelimiter;
  1231. -
  1232.     }
  1233. -
  1234.  
  1235. -
  1236.     /**
  1237. -
  1238.      * Call the /admin/ping servlet, can be used to quickly tell if a connection to the
  1239. -
  1240.      * server is able to be made.
  1241. -
  1242.      *
  1243. -
  1244.      * @param float $timeout maximum time to wait for ping in seconds, -1 for unlimited (default is 2)
  1245. -
  1246.      * @return float Actual time taken to ping the server, FALSE if timeout or HTTP error status occurs
  1247. -
  1248.      */
  1249. -
  1250.     public function ping($timeout 2)
  1251. -
  1252.     {
  1253. -
  1254.         $start microtime(true);
  1255. -
  1256.         
  1257. -
  1258.         $httpTransport $this->getHttpTransport();
  1259. -
  1260.  
  1261. -
  1262.         $httpResponse $httpTransport->performHeadRequest($this->_pingUrl$timeout);
  1263. -
  1264.         $solrResponse new Apache_Solr_Response($httpResponse$this->_createDocuments$this->_collapseSingleValueArrays);
  1265. -
  1266.  
  1267. -
  1268.         if ($solrResponse->getHttpStatus(== 200)
  1269. -
  1270.         {
  1271. -
  1272.             return microtime(true$start;
  1273. -
  1274.         }
  1275. -
  1276.         else
  1277. -
  1278.         {
  1279. -
  1280.             return false;
  1281. -
  1282.         }
  1283. -
  1284.     }
  1285. -
  1286.  
  1287. -
  1288.     /**
  1289. -
  1290.      * Call the /admin/threads servlet and retrieve information about all threads in the
  1291. -
  1292.      * Solr servlet's thread group. Useful for diagnostics.
  1293. -
  1294.      *
  1295. -
  1296.      * @return Apache_Solr_Response 
  1297. -
  1298.      *
  1299. -
  1300.      * @throws Apache_Solr_HttpTransportException If an error occurs during the service call
  1301. -
  1302.      */
  1303. -
  1304.     public function threads()
  1305. -
  1306.     {
  1307. -
  1308.         return $this->_sendRawGet($this->_threadsUrl);
  1309. -
  1310.     }
  1311. -
  1312.  
  1313. -
  1314.     /**
  1315. -
  1316.      * Raw Add Method. Takes a raw post body and sends it to the update service.  Post body
  1317. -
  1318.      * should be a complete and well formed "add" xml document.
  1319. -
  1320.      *
  1321. -
  1322.      * @param string $rawPost 
  1323. -
  1324.      * @return Apache_Solr_Response 
  1325. -
  1326.      *
  1327. -
  1328.      * @throws Apache_Solr_HttpTransportException If an error occurs during the service call
  1329. -
  1330.      */
  1331. -
  1332.     public function add($rawPost)
  1333. -
  1334.     {
  1335. -
  1336.         return $this->_sendRawPost($this->_updateUrl$rawPost);
  1337. -
  1338.     }
  1339. -
  1340.  
  1341. -
  1342.     /**
  1343. -
  1344.      * Add a Solr Document to the index
  1345. -
  1346.      *
  1347. -
  1348.      * @param Apache_Solr_Document $document 
  1349. -
  1350.      * @param boolean $allowDups 
  1351. -
  1352.      * @param boolean $overwritePending 
  1353. -
  1354.      * @param boolean $overwriteCommitted 
  1355. -
  1356.      * @param integer $commitWithin The number of milliseconds that a document must be committed within, see @{link http://wiki.apache.org/solr/UpdateXmlMessages#The_Update_Schema} for details.  If left empty this property will not be set in the request.
  1357. -
  1358.      * @return Apache_Solr_Response 
  1359. -
  1360.      *
  1361. -
  1362.      * @throws Apache_Solr_HttpTransportException If an error occurs during the service call
  1363. -
  1364.      */
  1365. -
  1366.     public function addDocument(Apache_Solr_Document $document$allowDups false$overwritePending true$overwriteCommitted true$commitWithin 0)
  1367. -
  1368.     {
  1369. -
  1370.         $dupValue $allowDups 'true' 'false';
  1371. -
  1372.         $pendingValue $overwritePending 'true' 'false';
  1373. -
  1374.         $committedValue $overwriteCommitted 'true' 'false';
  1375. -
  1376.         
  1377. -
  1378.         $commitWithin = (int) $commitWithin;
  1379. -
  1380.         $commitWithinString $commitWithin " commitWithin=\"{$commitWithin}\"'';
  1381. -
  1382.         
  1383. -
  1384.         $rawPost "<add allowDups=\"{$dupValue}\" overwritePending=\"{$pendingValue}\" overwriteCommitted=\"{$committedValue}\"{$commitWithinString}>";
  1385. -
  1386.         $rawPost .= $this->_documentToXmlFragment($document);
  1387. -
  1388.         $rawPost .= '</add>';
  1389. -
  1390.  
  1391. -
  1392.         return $this->add($rawPost);
  1393. -
  1394.     }
  1395. -
  1396.  
  1397. -
  1398.     /**
  1399. -
  1400.      * Add an array of Solr Documents to the index all at once
  1401. -
  1402.      *
  1403. -
  1404.      * @param array $documents Should be an array of Apache_Solr_Document instances
  1405. -
  1406.      * @param boolean $allowDups 
  1407. -
  1408.      * @param boolean $overwritePending 
  1409. -
  1410.      * @param boolean $overwriteCommitted 
  1411. -
  1412.      * @param integer $commitWithin The number of milliseconds that a document must be committed within, see @{link http://wiki.apache.org/solr/UpdateXmlMessages#The_Update_Schema} for details.  If left empty this property will not be set in the request.
  1413. -
  1414.      * @return Apache_Solr_Response 
  1415. -
  1416.      *
  1417. -
  1418.      * @throws Apache_Solr_HttpTransportException If an error occurs during the service call
  1419. -
  1420.      */
  1421. -
  1422.     public function addDocuments($documents$allowDups false$overwritePending true$overwriteCommitted true$commitWithin 0)
  1423. -
  1424.     {
  1425. -
  1426.         $dupValue $allowDups 'true' 'false';
  1427. -
  1428.         $pendingValue $overwritePending 'true' 'false';
  1429. -
  1430.         $committedValue $overwriteCommitted 'true' 'false';
  1431. -
  1432.  
  1433. -
  1434.         $commitWithin = (int) $commitWithin;
  1435. -
  1436.         $commitWithinString $commitWithin " commitWithin=\"{$commitWithin}\"'';
  1437. -
  1438.  
  1439. -
  1440.         $rawPost "<add allowDups=\"{$dupValue}\" overwritePending=\"{$pendingValue}\" overwriteCommitted=\"{$committedValue}\"{$commitWithinString}>";
  1441. -
  1442.  
  1443. -
  1444.         foreach ($documents as $document)
  1445. -
  1446.         {
  1447. -
  1448.             if ($document instanceof Apache_Solr_Document)
  1449. -
  1450.             {
  1451. -
  1452.                 $rawPost .= $this->_documentToXmlFragment($document);
  1453. -
  1454.             }
  1455. -
  1456.         }
  1457. -
  1458.  
  1459. -
  1460.         $rawPost .= '</add>';
  1461. -
  1462.  
  1463. -
  1464.         return $this->add($rawPost);
  1465. -
  1466.     }
  1467. -
  1468.  
  1469. -
  1470.     /**
  1471. -
  1472.      * Create an XML fragment from a {@link Apache_Solr_Document} instance appropriate for use inside a Solr add call
  1473. -
  1474.      *
  1475. -
  1476.      * @return string 
  1477. -
  1478.      */
  1479. -
  1480.     protected function _documentToXmlFragment(Apache_Solr_Document $document)
  1481. -
  1482.     {
  1483. -
  1484.         $xml '<doc';
  1485. -
  1486.  
  1487. -
  1488.         if ($document->getBoost(!== false)
  1489. -
  1490.         {
  1491. -
  1492.             $xml .= ' boost="' $document->getBoost('"';
  1493. -
  1494.         }
  1495. -
  1496.  
  1497. -
  1498.         $xml .= '>';
  1499. -
  1500.  
  1501. -
  1502.         foreach ($document as $key => $value)
  1503. -
  1504.         {
  1505. -
  1506.             $key htmlspecialchars($keyENT_QUOTES'UTF-8');
  1507. -
  1508.             $fieldBoost $document->getFieldBoost($key);
  1509. -
  1510.  
  1511. -
  1512.             if (is_array($value))
  1513. -
  1514.             {
  1515. -
  1516.                 foreach ($value as $multivalue)
  1517. -
  1518.                 {
  1519. -
  1520.                     $xml .= '<field name="' $key '"';
  1521. -
  1522.  
  1523. -
  1524.                     if ($fieldBoost !== false)
  1525. -
  1526.                     {
  1527. -
  1528.                         $xml .= ' boost="' $fieldBoost '"';
  1529. -
  1530.  
  1531. -
  1532.                         // only set the boost for the first field in the set
  1533. -
  1534.                         $fieldBoost false;
  1535. -
  1536.                     }
  1537. -
  1538.  
  1539. -
  1540.                     $multivalue htmlspecialchars($multivalueENT_NOQUOTES'UTF-8');
  1541. -
  1542.  
  1543. -
  1544.                     $xml .= '>' $multivalue '</field>';
  1545. -
  1546.                 }
  1547. -
  1548.             }
  1549. -
  1550.             else
  1551. -
  1552.             {
  1553. -
  1554.                 $xml .= '<field name="' $key '"';
  1555. -
  1556.  
  1557. -
  1558.                 if ($fieldBoost !== false)
  1559. -
  1560.                 {
  1561. -
  1562.                     $xml .= ' boost="' $fieldBoost '"';
  1563. -
  1564.                 }
  1565. -
  1566.  
  1567. -
  1568.                 $value htmlspecialchars($valueENT_NOQUOTES'UTF-8');
  1569. -
  1570.  
  1571. -
  1572.                 $xml .= '>' $value '</field>';
  1573. -
  1574.             }
  1575. -
  1576.         }
  1577. -
  1578.  
  1579. -
  1580.         $xml .= '</doc>';
  1581. -
  1582.  
  1583. -
  1584.         // replace any control characters to avoid Solr XML parser exception
  1585. -
  1586.         return $this->_stripCtrlChars($xml);
  1587. -
  1588.     }
  1589. -
  1590.  
  1591. -
  1592.     /**
  1593. -
  1594.      * Replace control (non-printable) characters from string that are invalid to Solr's XML parser with a space.
  1595. -
  1596.      *
  1597. -
  1598.      * @param string $string 
  1599. -
  1600.      * @return string 
  1601. -
  1602.      */
  1603. -
  1604.     protected function _stripCtrlChars($string)
  1605. -
  1606.     {
  1607. -
  1608.         // See:  http://w3.org/International/questions/qa-forms-utf-8.html
  1609. -
  1610.         // Printable utf-8 does not include any of these chars below x7F
  1611. -
  1612.         return preg_replace('@[\x00-\x08\x0B\x0C\x0E-\x1F]@'' '$string);
  1613. -
  1614.     }
  1615. -
  1616.  
  1617. -
  1618.     /**
  1619. -
  1620.      * Send a commit command.  Will be synchronous unless both wait parameters are set to false.
  1621. -
  1622.      *
  1623. -
  1624.      * @param boolean $expungeDeletes Defaults to false, merge segments with deletes away
  1625. -
  1626.      * @param boolean $waitFlush Defaults to true,  block until index changes are flushed to disk
  1627. -
  1628.      * @param boolean $waitSearcher Defaults to true, block until a new searcher is opened and registered as the main query searcher, making the changes visible
  1629. -
  1630.      * @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
  1631. -
  1632.      * @return Apache_Solr_Response 
  1633. -
  1634.      *
  1635. -
  1636.      * @throws Apache_Solr_HttpTransportException If an error occurs during the service call
  1637. -
  1638.      */
  1639. -
  1640.     public function commit($expungeDeletes false$waitFlush true$waitSearcher true$timeout 3600)
  1641. -
  1642.     {
  1643. -
  1644.         $expungeValue $expungeDeletes 'true' 'false';
  1645. -
  1646.         $flushValue $waitFlush 'true' 'false';
  1647. -
  1648.         $searcherValue $waitSearcher 'true' 'false';
  1649. -
  1650.  
  1651. -
  1652.         $rawPost '<commit expungeDeletes="' $expungeValue '" waitFlush="' $flushValue '" waitSearcher="' $searcherValue '" />';
  1653. -
  1654.  
  1655. -
  1656.         return $this->_sendRawPost($this->_updateUrl$rawPost$timeout);
  1657. -
  1658.     }
  1659. -
  1660.  
  1661. -
  1662.     /**
  1663. -
  1664.      * Raw Delete Method. Takes a raw post body and sends it to the update service. Body should be
  1665. -
  1666.      * a complete and well formed "delete" xml document
  1667. -
  1668.      *
  1669. -
  1670.      * @param string $rawPost Expected to be utf-8 encoded xml document
  1671. -
  1672.      * @param float $timeout Maximum expected duration of the delete operation on the server (otherwise, will throw a communication exception)
  1673. -
  1674.      * @return Apache_Solr_Response 
  1675. -
  1676.      *
  1677. -
  1678.      * @throws Apache_Solr_HttpTransportException If an error occurs during the service call
  1679. -
  1680.      */
  1681. -
  1682.     public function delete($rawPost$timeout 3600)
  1683. -
  1684.     {
  1685. -
  1686.         return $this->_sendRawPost($this->_updateUrl$rawPost$timeout);
  1687. -
  1688.     }
  1689. -
  1690.  
  1691. -
  1692.     /**
  1693. -
  1694.      * Create a delete document based on document ID
  1695. -
  1696.      *
  1697. -
  1698.      * @param string $id Expected to be utf-8 encoded
  1699. -
  1700.      * @param boolean $fromPending 
  1701. -
  1702.      * @param boolean $fromCommitted 
  1703. -
  1704.      * @param float $timeout Maximum expected duration of the delete operation on the server (otherwise, will throw a communication exception)
  1705. -
  1706.      * @return Apache_Solr_Response 
  1707. -
  1708.      *
  1709. -
  1710.      * @throws Apache_Solr_HttpTransportException If an error occurs during the service call
  1711. -
  1712.      */
  1713. -
  1714.     public function deleteById($id$fromPending true$fromCommitted true$timeout 3600)
  1715. -
  1716.     {
  1717. -
  1718.         $pendingValue $fromPending 'true' 'false';
  1719. -
  1720.         $committedValue $fromCommitted 'true' 'false';
  1721. -
  1722.  
  1723. -
  1724.         //escape special xml characters
  1725. -
  1726.         $id htmlspecialchars($idENT_NOQUOTES'UTF-8');
  1727. -
  1728.  
  1729. -
  1730.         $rawPost '<delete fromPending="' $pendingValue '" fromCommitted="' $committedValue '"><id>' $id '</id></delete>';
  1731. -
  1732.  
  1733. -
  1734.         return $this->delete($rawPost$timeout);
  1735. -
  1736.     }
  1737. -
  1738.  
  1739. -
  1740.     /**
  1741. -
  1742.      * Create and post a delete document based on multiple document IDs.
  1743. -
  1744.      *
  1745. -
  1746.      * @param array $ids Expected to be utf-8 encoded strings
  1747. -
  1748.      * @param boolean $fromPending 
  1749. -
  1750.      * @param boolean $fromCommitted 
  1751. -
  1752.      * @param float $timeout Maximum expected duration of the delete operation on the server (otherwise, will throw a communication exception)
  1753. -
  1754.      * @return Apache_Solr_Response 
  1755. -
  1756.      *
  1757. -
  1758.      * @throws Apache_Solr_HttpTransportException If an error occurs during the service call
  1759. -
  1760.      */
  1761. -
  1762.     public function deleteByMultipleIds($ids$fromPending true$fromCommitted true$timeout 3600)
  1763. -
  1764.     {
  1765. -
  1766.         $pendingValue $fromPending 'true' 'false';
  1767. -
  1768.         $committedValue $fromCommitted 'true' 'false';
  1769. -
  1770.  
  1771. -
  1772.         $rawPost '<delete fromPending="' $pendingValue '" fromCommitted="' $committedValue '">';
  1773. -
  1774.  
  1775. -
  1776.         foreach ($ids as $id)
  1777. -
  1778.         {
  1779. -
  1780.             //escape special xml characters
  1781. -
  1782.             $id htmlspecialchars($idENT_NOQUOTES'UTF-8');
  1783. -
  1784.  
  1785. -
  1786.             $rawPost .= '<id>' $id '</id>';
  1787. -
  1788.         }
  1789. -
  1790.  
  1791. -
  1792.         $rawPost .= '</delete>';
  1793. -
  1794.  
  1795. -
  1796.         return $this->delete($rawPost$timeout);
  1797. -
  1798.     }
  1799. -
  1800.  
  1801. -
  1802.     /**
  1803. -
  1804.      * Create a delete document based on a query and submit it
  1805. -
  1806.      *
  1807. -
  1808.      * @param string $rawQuery Expected to be utf-8 encoded
  1809. -
  1810.      * @param boolean $fromPending 
  1811. -
  1812.      * @param boolean $fromCommitted 
  1813. -
  1814.      * @param float $timeout Maximum expected duration of the delete operation on the server (otherwise, will throw a communication exception)
  1815. -
  1816.      * @return Apache_Solr_Response 
  1817. -
  1818.      *
  1819. -
  1820.      * @throws Apache_Solr_HttpTransportException If an error occurs during the service call
  1821. -
  1822.      */
  1823. -
  1824.     public function deleteByQuery($rawQuery$fromPending true$fromCommitted true$timeout 3600)
  1825. -
  1826.     {
  1827. -
  1828.         $pendingValue $fromPending 'true' 'false';
  1829. -
  1830.         $committedValue $fromCommitted 'true' 'false';
  1831. -
  1832.  
  1833. -
  1834.         // escape special xml characters
  1835. -
  1836.         $rawQuery htmlspecialchars($rawQueryENT_NOQUOTES'UTF-8');
  1837. -
  1838.  
  1839. -
  1840.         $rawPost '<delete fromPending="' $pendingValue '" fromCommitted="' $committedValue '"><query>' $rawQuery '</query></delete>';
  1841. -
  1842.  
  1843. -
  1844.         return $this->delete($rawPost$timeout);
  1845. -
  1846.     }
  1847. -
  1848.  
  1849. -
  1850.     /**
  1851. -
  1852.      * Use Solr Cell to extract document contents. See {@link http://wiki.apache.org/solr/ExtractingRequestHandler} for information on how
  1853. -
  1854.      * to use Solr Cell and what parameters are available.
  1855. -
  1856.      *
  1857. -
  1858.      * NOTE: when passing an Apache_Solr_Document instance, field names and boosts will automatically be prepended by "literal." and "boost."
  1859. -
  1860.      * as appropriate. Any keys from the $params array will NOT be treated this way. Any mappings from the document will overwrite key / value
  1861. -
  1862.      * pairs in the params array if they have the same name (e.g. you pass a "literal.id" key and value in your $params array but you also
  1863. -
  1864.      * pass in a document isntance with an "id" field" - the document's value(s) will take precedence).
  1865. -
  1866.      *
  1867. -
  1868.      * @param string $file Path to file to extract data from
  1869. -
  1870.      * @param array $params optional array of key value pairs that will be sent with the post (see Solr Cell documentation)
  1871. -
  1872.      * @param Apache_Solr_Document $document optional document that will be used to generate post parameters (literal.* and boost.* params)
  1873. -
  1874.      * @param string $mimetype optional mimetype specification (for the file being extracted)
  1875. -
  1876.      *
  1877. -
  1878.      * @return Apache_Solr_Response 
  1879. -
  1880.      *
  1881. -
  1882.      * @throws Apache_Solr_InvalidArgumentException if $file, $params, or $document are invalid.
  1883. -
  1884.      */
  1885. -
  1886.     public function extract($file$params array()$document null$mimetype 'application/octet-stream')
  1887. -
  1888.     {
  1889. -
  1890.         // check if $params is an array (allow null for default empty array)
  1891. -
  1892.         if (!is_null($params))
  1893. -
  1894.         {
  1895. -
  1896.             if (!is_array($params))
  1897. -
  1898.             {
  1899. -
  1900.                 throw new Apache_Solr_InvalidArgumentException("\$params must be a valid array or null");
  1901. -
  1902.             }
  1903. -
  1904.         }
  1905. -
  1906.         else
  1907. -
  1908.         {
  1909. -
  1910.             $params array();
  1911. -
  1912.         }
  1913. -
  1914.         
  1915. -
  1916.         // if $file is an http request, defer to extractFromUrl instead
  1917. -
  1918.         if (substr($file07== 'http://' || substr($file08== 'https://')
  1919. -
  1920.         {
  1921. -
  1922.             return $this->extractFromUrl($file$params$document$mimetype);
  1923. -
  1924.         }
  1925. -
  1926.         
  1927. -
  1928.         // read the contents of the file
  1929. -
  1930.         $contents @file_get_contents($file);
  1931. -
  1932.  
  1933. -
  1934.         if ($contents !== false)
  1935. -
  1936.         {
  1937. -
  1938.             // add the resource.name parameter if not specified
  1939. -
  1940.             if (!isset($params['resource.name']))
  1941. -
  1942.             {
  1943. -
  1944.                 $params['resource.name'basename($file);
  1945. -
  1946.             }
  1947. -
  1948.  
  1949. -
  1950.             // delegate the rest to extractFromString
  1951. -
  1952.             return $this->extractFromString($contents$params$document$mimetype);
  1953. -
  1954.         }
  1955. -
  1956.         else
  1957. -
  1958.         {
  1959. -
  1960.             throw new Apache_Solr_InvalidArgumentException("File '{$file}' is empty or could not be read");
  1961. -
  1962.         }
  1963. -
  1964.     }
  1965. -
  1966.     
  1967. -
  1968.     /**
  1969. -
  1970.      * Use Solr Cell to extract document contents. See {@link http://wiki.apache.org/solr/ExtractingRequestHandler} for information on how
  1971. -
  1972.      * to use Solr Cell and what parameters are available.
  1973. -
  1974.      *
  1975. -
  1976.      * NOTE: when passing an Apache_Solr_Document instance, field names and boosts will automatically be prepended by "literal." and "boost."
  1977. -
  1978.      * as appropriate. Any keys from the $params array will NOT be treated this way. Any mappings from the document will overwrite key / value
  1979. -
  1980.      * pairs in the params array if they have the same name (e.g. you pass a "literal.id" key and value in your $params array but you also
  1981. -
  1982.      * pass in a document isntance with an "id" field" - the document's value(s) will take precedence).
  1983. -
  1984.      *
  1985. -
  1986.      * @param string $data Data that will be passed to Solr Cell
  1987. -
  1988.      * @param array $params optional array of key value pairs that will be sent with the post (see Solr Cell documentation)
  1989. -
  1990.      * @param Apache_Solr_Document $document optional document that will be used to generate post parameters (literal.* and boost.* params)
  1991. -
  1992.      * @param string $mimetype optional mimetype specification (for the file being extracted)
  1993. -
  1994.      *
  1995. -
  1996.      * @return Apache_Solr_Response 
  1997. -
  1998.      *
  1999. -
  2000.      * @throws Apache_Solr_InvalidArgumentException if $file, $params, or $document are invalid.
  2001. -
  2002.      *
  2003. -
  2004.      * @todo Should be using multipart/form-data to post parameter values, but I could not get my implementation to work. Needs revisisted.
  2005. -
  2006.      */
  2007. -
  2008.     public function extractFromString($data$params array()$document null$mimetype 'application/octet-stream')
  2009. -
  2010.     {
  2011. -
  2012.         // check if $params is an array (allow null for default empty array)
  2013. -
  2014.         if (!is_null($params))
  2015. -
  2016.         {
  2017. -
  2018.             if (!is_array($params))
  2019. -
  2020.             {
  2021. -
  2022.                 throw new Apache_Solr_InvalidArgumentException("\$params must be a valid array or null");
  2023. -
  2024.             }
  2025. -
  2026.         }
  2027. -
  2028.         else
  2029. -
  2030.         {
  2031. -
  2032.             $params array();
  2033. -
  2034.         }
  2035. -
  2036.  
  2037. -
  2038.         // make sure we receive our response in JSON and have proper name list treatment
  2039. -
  2040.         $params['wt'self::SOLR_WRITER;
  2041. -
  2042.         $params['json.nl'$this->_namedListTreatment;
  2043. -
  2044.  
  2045. -
  2046.         // check if $document is an Apache_Solr_Document instance
  2047. -
  2048.         if (!is_null($document&& $document instanceof Apache_Solr_Document)
  2049. -
  2050.         {
  2051. -
  2052.             // iterate document, adding literal.* and boost.* fields to $params as appropriate
  2053. -
  2054.             foreach ($document as $field => $fieldValue)
  2055. -
  2056.             {
  2057. -
  2058.                 // check if we need to add a boost.* parameters
  2059. -
  2060.                 $fieldBoost $document->getFieldBoost($field);
  2061. -
  2062.  
  2063. -
  2064.                 if ($fieldBoost !== false)
  2065. -
  2066.                 {
  2067. -
  2068.                     $params["boost.{$field}"$fieldBoost;
  2069. -
  2070.                 }
  2071. -
  2072.  
  2073. -
  2074.                 // add the literal.* parameter
  2075. -
  2076.                 $params["literal.{$field}"$fieldValue;
  2077. -
  2078.             }
  2079. -
  2080.         }
  2081. -
  2082.  
  2083. -
  2084.         // params will be sent to SOLR in the QUERY STRING
  2085. -
  2086.         $queryString $this->_generateQueryString($params);
  2087. -
  2088.  
  2089. -
  2090.         // the file contents will be sent to SOLR as the POST BODY - we use application/octect-stream as default mimetype
  2091. -
  2092.         return $this->_sendRawPost($this->_extractUrl $this->_queryDelimiter . $queryString$datafalse$mimetype);
  2093. -
  2094.     }
  2095. -
  2096.     
  2097. -
  2098.     /**
  2099. -
  2100.      * Use Solr Cell to extract document contents. See {@link http://wiki.apache.org/solr/ExtractingRequestHandler} for information on how
  2101. -
  2102.      * to use Solr Cell and what parameters are available.
  2103. -
  2104.      *
  2105. -
  2106.      * NOTE: when passing an Apache_Solr_Document instance, field names and boosts will automatically be prepended by "literal." and "boost."
  2107. -
  2108.      * as appropriate. Any keys from the $params array will NOT be treated this way. Any mappings from the document will overwrite key / value
  2109. -
  2110.      * pairs in the params array if they have the same name (e.g. you pass a "literal.id" key and value in your $params array but you also
  2111. -
  2112.      * pass in a document isntance with an "id" field" - the document's value(s) will take precedence).
  2113. -
  2114.      *
  2115. -
  2116.      * @param string $url URL
  2117. -
  2118.      * @param array $params optional array of key value pairs that will be sent with the post (see Solr Cell documentation)
  2119. -
  2120.      * @param Apache_Solr_Document $document optional document that will be used to generate post parameters (literal.* and boost.* params)
  2121. -
  2122.      * @param string $mimetype optional mimetype specification (for the file being extracted)
  2123. -
  2124.      *
  2125. -
  2126.      * @return Apache_Solr_Response 
  2127. -
  2128.      *
  2129. -
  2130.      * @throws Apache_Solr_InvalidArgumentException if $url, $params, or $document are invalid.
  2131. -
  2132.      */
  2133. -
  2134.     public function extractFromUrl($url$params array()$document null$mimetype 'application/octet-stream')
  2135. -
  2136.     {
  2137. -
  2138.         // check if $params is an array (allow null for default empty array)
  2139. -
  2140.         if (!is_null($params))
  2141. -
  2142.         {
  2143. -
  2144.             if (!is_array($params))
  2145. -
  2146.             {
  2147. -
  2148.                 throw new Apache_Solr_InvalidArgumentException("\$params must be a valid array or null");
  2149. -
  2150.             }
  2151. -
  2152.         }
  2153. -
  2154.         else
  2155. -
  2156.         {
  2157. -
  2158.             $params array();
  2159. -
  2160.         }
  2161. -
  2162.  
  2163. -
  2164.         $httpTransport $this->getHttpTransport();
  2165. -
  2166.         
  2167. -
  2168.         // read the contents of the URL using our configured Http Transport and default timeout
  2169. -
  2170.         $httpResponse $httpTransport->performGetRequest($url);
  2171. -
  2172.         
  2173. -
  2174.         // check that its a 200 response
  2175. -
  2176.         if ($httpResponse->getStatusCode(== 200)
  2177. -
  2178.         {
  2179. -
  2180.             // add the resource.name parameter if not specified
  2181. -
  2182.             if (!isset($params['resource.name']))
  2183. -
  2184.             {
  2185. -
  2186.                 $params['resource.name'$url;
  2187. -
  2188.             }
  2189. -
  2190.  
  2191. -
  2192.             // delegate the rest to extractFromString
  2193. -
  2194.             return $this->extractFromString($httpResponse->getBody()$params$document$mimetype);
  2195. -
  2196.         }
  2197. -
  2198.         else
  2199. -
  2200.         {
  2201. -
  2202.             throw new Apache_Solr_InvalidArgumentException("URL '{$url}' returned non 200 response code");
  2203. -
  2204.         }
  2205. -
  2206.     }
  2207. -
  2208.  
  2209. -
  2210.     /**
  2211. -
  2212.      * Send an optimize command.  Will be synchronous unless both wait parameters are set
  2213. -
  2214.      * to false.
  2215. -
  2216.      *
  2217. -
  2218.      * @param boolean $waitFlush 
  2219. -
  2220.      * @param boolean $waitSearcher 
  2221. -
  2222.      * @param float $timeout Maximum expected duration of the commit operation on the server (otherwise, will throw a communication exception)
  2223. -
  2224.      * @return Apache_Solr_Response 
  2225. -
  2226.      *
  2227. -
  2228.      * @throws Apache_Solr_HttpTransportException If an error occurs during the service call
  2229. -
  2230.      */
  2231. -
  2232.     public function optimize($waitFlush true$waitSearcher true$timeout 3600)
  2233. -
  2234.     {
  2235. -
  2236.         $flushValue $waitFlush 'true' 'false';
  2237. -
  2238.         $searcherValue $waitSearcher 'true' 'false';
  2239. -
  2240.  
  2241. -
  2242.         $rawPost '<optimize waitFlush="' $flushValue '" waitSearcher="' $searcherValue '" />';
  2243. -
  2244.  
  2245. -
  2246.         return $this->_sendRawPost($this->_updateUrl$rawPost$timeout);
  2247. -
  2248.     }
  2249. -
  2250.  
  2251. -
  2252.     /**
  2253. -
  2254.      * Simple Search interface
  2255. -
  2256.      *
  2257. -
  2258.      * @param string $query The raw query string
  2259. -
  2260.      * @param int $offset The starting offset for result documents
  2261. -
  2262.      * @param int $limit The maximum number of result documents to return
  2263. -
  2264.      * @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)
  2265. -
  2266.      * @param string $method The HTTP method (Apache_Solr_Service::METHOD_GET or Apache_Solr_Service::METHOD::POST)
  2267. -
  2268.      * @return Apache_Solr_Response 
  2269. -
  2270.      *
  2271. -
  2272.      * @throws Apache_Solr_HttpTransportException If an error occurs during the service call
  2273. -
  2274.      * @throws Apache_Solr_InvalidArgumentException If an invalid HTTP method is used
  2275. -
  2276.      */
  2277. -
  2278.     public function search($query$offset 0$limit 10$params array()$method self::METHOD_GET)
  2279. -
  2280.     {
  2281. -
  2282.         // ensure params is an array
  2283. -
  2284.         if (!is_null($params))
  2285. -
  2286.         {
  2287. -
  2288.             if (!is_array($params))
  2289. -
  2290.             {
  2291. -
  2292.                 // params was specified but was not an array - invalid
  2293. -
  2294.                 throw new Apache_Solr_InvalidArgumentException("\$params must be a valid array or null");
  2295. -
  2296.             }
  2297. -
  2298.         }
  2299. -
  2300.         else
  2301. -
  2302.         {
  2303. -
  2304.             $params array();
  2305. -
  2306.         }
  2307. -
  2308.         
  2309. -
  2310.         // construct our full parameters
  2311. -
  2312.  
  2313. -
  2314.         // common parameters in this interface
  2315. -
  2316.         $params['wt'self::SOLR_WRITER;
  2317. -
  2318.         $params['json.nl'$this->_namedListTreatment;
  2319. -
  2320.  
  2321. -
  2322.         $params['q'$query;
  2323. -
  2324.         $params['start'$offset;
  2325. -
  2326.         $params['rows'$limit;
  2327. -
  2328.  
  2329. -
  2330.         $queryString $this->_generateQueryString($params);
  2331. -
  2332.  
  2333. -
  2334.         if ($method == self::METHOD_GET)
  2335. -
  2336.         {
  2337. -
  2338.             return $this->_sendRawGet($this->_searchUrl . $this->_queryDelimiter . $queryString);
  2339. -
  2340.         }
  2341. -
  2342.         else if ($method == self::METHOD_POST)
  2343. -
  2344.         {
  2345. -
  2346.             return $this->_sendRawPost($this->_searchUrl$queryStringFALSE'application/x-www-form-urlencoded; charset=UTF-8');
  2347. -
  2348.         }
  2349. -
  2350.         else
  2351. -
  2352.         {
  2353. -
  2354.             throw new Apache_Solr_InvalidArgumentException("Unsupported method '$method', please use the Apache_Solr_Service::METHOD_* constants");
  2355. -
  2356.         }
  2357. -
  2358.     }
  2359. -
  2360. }
  2361. -
-
-

- Documentation generated on Wed, 04 May 2011 11:01:19 -0400 by phpDocumentor 1.4.3 -

- - \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_ServiceBalancer.php.html b/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_ServiceBalancer.php.html deleted file mode 100644 index f7707cd1..00000000 --- a/SolrPhpClient/phpdocs/__filesource/fsource_Apache_Solr_ServiceBalancer.php.html +++ /dev/null @@ -1,934 +0,0 @@ - - - - - - File Source for Balancer.php - - - - -

Source for file Balancer.php

-

Documentation is available at Balancer.php

-
-
  1. <?php
  2. -
  3. /**
  4. -
  5.  * Copyright (c) 2007-2011, Servigistics, Inc.
  6. -
  7.  * All rights reserved.
  8. -
  9.  *
  10. -
  11.  * Redistribution and use in source and binary forms, with or without
  12. -
  13.  * modification, are permitted provided that the following conditions are met:
  14. -
  15.  *
  16. -
  17.  *  - Redistributions of source code must retain the above copyright notice,
  18. -
  19.  *    this list of conditions and the following disclaimer.
  20. -
  21.  *  - Redistributions in binary form must reproduce the above copyright
  22. -
  23.  *    notice, this list of conditions and the following disclaimer in the
  24. -
  25.  *    documentation and/or other materials provided with the distribution.
  26. -
  27.  *  - Neither the name of Servigistics, Inc. nor the names of
  28. -
  29.  *    its contributors may be used to endorse or promote products derived from
  30. -
  31.  *    this software without specific prior written permission.
  32. -
  33.  *
  34. -
  35.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  36. -
  37.  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  38. -
  39.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  40. -
  41.  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  42. -
  43.  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  44. -
  45.  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  46. -
  47.  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  48. -
  49.  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  50. -
  51.  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  52. -
  53.  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  54. -
  55.  * POSSIBILITY OF SUCH DAMAGE.
  56. -
  57.  *
  58. -
  59.  * @copyright Copyright 2007-2011 Servigistics, Inc. (http://servigistics.com)
  60. -
  61.  * @license http://solr-php-client.googlecode.com/svn/trunk/COPYING New BSD
  62. -
  63.  * @version $Id: Balancer.php 54 2011-02-04 16:29:18Z donovan.jimenez $
  64. -
  65.  *
  66. -
  67.  * @package Apache
  68. -
  69.  * @subpackage Solr
  70. -
  71.  * @author Donovan Jimenez <djimenez@conduit-it.com>, Dan Wolfe
  72. -
  73.  */
  74. -
  75.  
  76. -
  77. // See Issue #1 (http://code.google.com/p/solr-php-client/issues/detail?id=1)
  78. -
  79. // Doesn't follow typical include path conventions, but is more convenient for users
  80. -
  81. require_once(dirname(dirname(__FILE__)) '/Service.php');
  82. -
  83.  
  84. -
  85. require_once(dirname(dirname(__FILE__)) '/NoServiceAvailableException.php');
  86. -
  87.  
  88. -
  89. /**
  90. -
  91.  * Reference Implementation for using multiple Solr services in a distribution. Functionality
  92. -
  93.  * includes:
  94. -
  95.  *     routing of read / write operations
  96. -
  97.  *     failover (on selection) for multiple read servers
  98. -
  99.  */
  100. -
  101. -
  102. {
  103. -
  104.     /**
  105. -
  106.      * SVN Revision meta data for this class
  107. -
  108.      */
  109. -
  110.     const SVN_REVISION '$Revision: 54 $';
  111. -
  112.  
  113. -
  114.     /**
  115. -
  116.      * SVN ID meta data for this class
  117. -
  118.      */
  119. -
  120.     const SVN_ID '$Id: Balancer.php 54 2011-02-04 16:29:18Z donovan.jimenez $';
  121. -
  122.  
  123. -
  124.     protected $_createDocuments = true;
  125. -
  126.  
  127. -
  128.     protected $_readableServices = array();
  129. -
  130.     protected $_writeableServices = array();
  131. -
  132.  
  133. -
  134.     protected $_currentReadService = null;
  135. -
  136.     protected $_currentWriteService = null;
  137. -
  138.  
  139. -
  140.     protected $_readPingTimeout = 2;
  141. -
  142.     protected $_writePingTimeout = 4;
  143. -
  144.  
  145. -
  146.     // Configuration for server selection backoff intervals
  147. -
  148.     protected $_useBackoff = false;        // Set to true to use more resillient write server selection
  149. -
  150.     protected $_backoffLimit = 600;        // 10 minute default maximum
  151. -
  152.     protected $_backoffEscalation = 2.0;     // Rate at which to increase backoff period
  153. -
  154.     protected $_defaultBackoff = 2.0;        // Default backoff interval
  155. -
  156.  
  157. -
  158.     /**
  159. -
  160.      * Escape a value for special query characters such as ':', '(', ')', '*', '?', etc.
  161. -
  162.      *
  163. -
  164.      * NOTE: inside a phrase fewer characters need escaped, use {@link Apache_Solr_Service::escapePhrase()} instead
  165. -
  166.      *
  167. -
  168.      * @param string $value 
  169. -
  170.      * @return string 
  171. -
  172.      */
  173. -
  174.     static public function escape($value)
  175. -
  176.     {
  177. -
  178.         return Apache_Solr_Service::escape($value);
  179. -
  180.     }
  181. -
  182.  
  183. -
  184.     /**
  185. -
  186.      * Escape a value meant to be contained in a phrase for special query characters
  187. -
  188.      *
  189. -
  190.      * @param string $value 
  191. -
  192.      * @return string 
  193. -
  194.      */
  195. -
  196.     static public function escapePhrase($value)
  197. -
  198.     {
  199. -
  200.         return Apache_Solr_Service::escapePhrase($value);
  201. -
  202.     }
  203. -
  204.  
  205. -
  206.     /**
  207. -
  208.      * Convenience function for creating phrase syntax from a value
  209. -
  210.      *
  211. -
  212.      * @param string $value 
  213. -
  214.      * @return string 
  215. -
  216.      */
  217. -
  218.     static public function phrase($value)
  219. -
  220.     {
  221. -
  222.         return Apache_Solr_Service::phrase($value);
  223. -
  224.     }
  225. -
  226.  
  227. -
  228.     /**
  229. -
  230.      * Constructor. Takes arrays of read and write service instances or descriptions
  231. -
  232.      *
  233. -
  234.      * @param array $readableServices 
  235. -
  236.      * @param array $writeableServices 
  237. -
  238.      */
  239. -
  240.     public function __construct($readableServices array()$writeableServices array())
  241. -
  242.     {
  243. -
  244.         //setup readable services
  245. -
  246.         foreach ($readableServices as $service)
  247. -
  248.         {
  249. -
  250.             $this->addReadService($service);
  251. -
  252.         }
  253. -
  254.  
  255. -
  256.         //setup writeable services
  257. -
  258.         foreach ($writeableServices as $service)
  259. -
  260.         {
  261. -
  262.             $this->addWriteService($service);
  263. -
  264.         }
  265. -
  266.     }
  267. -
  268.  
  269. -
  270.     public function setReadPingTimeout($timeout)
  271. -
  272.     {
  273. -
  274.         $this->_readPingTimeout = $timeout;
  275. -
  276.     }
  277. -
  278.  
  279. -
  280.     public function setWritePingTimeout($timeout)
  281. -
  282.     {
  283. -
  284.         $this->_writePingTimeout = $timeout;
  285. -
  286.     }
  287. -
  288.  
  289. -
  290.     public function setUseBackoff($enable)
  291. -
  292.     {
  293. -
  294.         $this->_useBackoff = $enable;
  295. -
  296.     }
  297. -
  298.  
  299. -
  300.     /**
  301. -
  302.      * Generates a service ID
  303. -
  304.      *
  305. -
  306.      * @param string $host 
  307. -
  308.      * @param integer $port 
  309. -
  310.      * @param string $path 
  311. -
  312.      * @return string 
  313. -
  314.      */
  315. -
  316.     protected function _getServiceId($host$port$path)
  317. -
  318.     {
  319. -
  320.         return $host ':' $port $path;
  321. -
  322.     }
  323. -
  324.  
  325. -
  326.     /**
  327. -
  328.      * Adds a service instance or service descriptor (if it is already
  329. -
  330.      * not added)
  331. -
  332.      *
  333. -
  334.      * @param mixed $service 
  335. -
  336.      *
  337. -
  338.      * @throws Apache_Solr_InvalidArgumentException If service descriptor is not valid
  339. -
  340.      */
  341. -
  342.     public function addReadService($service)
  343. -
  344.     {
  345. -
  346.         if ($service instanceof Apache_Solr_Service)
  347. -
  348.         {
  349. -
  350.             $id $this->_getServiceId($service->getHost()$service->getPort()$service->getPath());
  351. -
  352.  
  353. -
  354.             $this->_readableServices[$id$service;
  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.                 $this->_readableServices[$id$service;
  371. -
  372.             }
  373. -
  374.             else
  375. -
  376.             {
  377. -
  378.                 throw new Apache_Solr_InvalidArgumentException('A Readable Service description array does not have all required elements of host, port, and path');
  379. -
  380.             }
  381. -
  382.         }
  383. -
  384.     }
  385. -
  386.  
  387. -
  388.     /**
  389. -
  390.      * Removes a service instance or descriptor from the available services
  391. -
  392.      *
  393. -
  394.      * @param mixed $service 
  395. -
  396.      *
  397. -
  398.      * @throws Apache_Solr_InvalidArgumentException If service descriptor is not valid
  399. -
  400.      */
  401. -
  402.     public function removeReadService($service)
  403. -
  404.     {
  405. -
  406.         $id '';
  407. -
  408.  
  409. -
  410.         if ($service instanceof Apache_Solr_Service)
  411. -
  412.         {
  413. -
  414.             $id $this->_getServiceId($service->getHost()$service->getPort()$service->getPath());
  415. -
  416.         }
  417. -
  418.         else if (is_array($service))
  419. -
  420.         {
  421. -
  422.             if (isset($service['host']&& isset($service['port']&& isset($service['path']))
  423. -
  424.             {
  425. -
  426.                 $id $this->_getServiceId((string)$service['host'](int)$service['port'](string)$service['path']);
  427. -
  428.             }
  429. -
  430.             else
  431. -
  432.             {
  433. -
  434.                 throw new Apache_Solr_InvalidArgumentException('A Readable Service description array does not have all required elements of host, port, and path');
  435. -
  436.             }
  437. -
  438.         }
  439. -
  440.         else if (is_string($service))
  441. -
  442.         {
  443. -
  444.             $id $service;
  445. -
  446.         }
  447. -
  448.  
  449. -
  450.         if ($id && isset($this->_readableServices[$id]))
  451. -
  452.         {
  453. -
  454.             unset($this->_readableServices[$id]);
  455. -
  456.         }
  457. -
  458.     }
  459. -
  460.  
  461. -
  462.     /**
  463. -
  464.      * Adds a service instance or service descriptor (if it is already
  465. -
  466.      * not added)
  467. -
  468.      *
  469. -
  470.      * @param mixed $service 
  471. -
  472.      *
  473. -
  474.      * @throws Apache_Solr_InvalidArgumentException If service descriptor is not valid
  475. -
  476.      */
  477. -
  478.     public function addWriteService($service)
  479. -
  480.     {
  481. -
  482.         if ($service instanceof Apache_Solr_Service)
  483. -
  484.         {
  485. -
  486.             $id $this->_getServiceId($service->getHost()$service->getPort()$service->getPath());
  487. -
  488.  
  489. -
  490.             $this->_writeableServices[$id$service;
  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.                 $this->_writeableServices[$id$service;
  507. -
  508.             }
  509. -
  510.             else
  511. -
  512.             {
  513. -
  514.                 throw new Apache_Solr_InvalidArgumentException('A Writeable Service description array does not have all required elements of host, port, and path');
  515. -
  516.             }
  517. -
  518.         }
  519. -
  520.     }
  521. -
  522.  
  523. -
  524.     /**
  525. -
  526.      * Removes a service instance or descriptor from the available services
  527. -
  528.      *
  529. -
  530.      * @param mixed $service 
  531. -
  532.      *
  533. -
  534.      * @throws Apache_Solr_InvalidArgumentException If service descriptor is not valid
  535. -
  536.      */
  537. -
  538.     public function removeWriteService($service)
  539. -
  540.     {
  541. -
  542.         $id '';
  543. -
  544.  
  545. -
  546.         if ($service instanceof Apache_Solr_Service)
  547. -
  548.         {
  549. -
  550.             $id $this->_getServiceId($service->getHost()$service->getPort()$service->getPath());
  551. -
  552.         }
  553. -
  554.         else if (is_array($service))
  555. -
  556.         {
  557. -
  558.             if (isset($service['host']&& isset($service['port']&& isset($service['path']))
  559. -
  560.             {
  561. -
  562.                 $id $this->_getServiceId((string)$service['host'](int)$service['port'](string)$service['path']);
  563. -
  564.             }
  565. -
  566.             else
  567. -
  568.             {
  569. -
  570.                 throw new Apache_Solr_InvalidArgumentException('A Readable Service description array does not have all required elements of host, port, and path');
  571. -
  572.             }
  573. -
  574.         }
  575. -
  576.         else if (is_string($service))
  577. -
  578.         {
  579. -
  580.             $id $service;
  581. -
  582.         }
  583. -
  584.  
  585. -
  586.         if ($id && isset($this->_writeableServices[$id]))
  587. -
  588.         {
  589. -
  590.             unset($this->_writeableServices[$id]);
  591. -
  592.         }
  593. -
  594.     }
  595. -
  596.  
  597. -
  598.     /**
  599. -
  600.      * Iterate through available read services and select the first with a ping
  601. -
  602.      * that satisfies configured timeout restrictions (or the default)
  603. -
  604.      *
  605. -
  606.      * @return Apache_Solr_Service 
  607. -
  608.      *
  609. -
  610.      * @throws Apache_Solr_NoServiceAvailableException If there are no read services that meet requirements
  611. -
  612.      */
  613. -
  614.     protected function _selectReadService($forceSelect false)
  615. -
  616.     {
  617. -
  618.         if (!$this->_currentReadService || !isset($this->_readableServices[$this->_currentReadService]|| $forceSelect)
  619. -
  620.         {
  621. -
  622.             if ($this->_currentReadService && isset($this->_readableServices[$this->_currentReadService]&& $forceSelect)
  623. -
  624.             {
  625. -
  626.                 // we probably had a communication error, ping the current read service, remove it if it times out
  627. -
  628.                 if ($this->_readableServices[$this->_currentReadService]->ping($this->_readPingTimeout=== false)
  629. -
  630.                 {
  631. -
  632.                     $this->removeReadService($this->_currentReadService);
  633. -
  634.                 }
  635. -
  636.             }
  637. -
  638.  
  639. -
  640.             if (count($this->_readableServices))
  641. -
  642.             {
  643. -
  644.                 // select one of the read services at random
  645. -
  646.                 $ids array_keys($this->_readableServices);
  647. -
  648.  
  649. -
  650.                 $id $ids[rand(0count($ids1)];
  651. -
  652.                 $service $this->_readableServices[$id];
  653. -
  654.  
  655. -
  656.                 if (is_array($service))
  657. -
  658.                 {
  659. -
  660.                     //convert the array definition to a client object
  661. -
  662.                     $service new Apache_Solr_Service($service['host']$service['port']$service['path']);
  663. -
  664.                     $this->_readableServices[$id$service;
  665. -
  666.                 }
  667. -
  668.  
  669. -
  670.                 $service->setCreateDocuments($this->_createDocuments);
  671. -
  672.                 $this->_currentReadService = $id;
  673. -
  674.             }
  675. -
  676.             else
  677. -
  678.             {
  679. -
  680.                 throw new Apache_Solr_NoServiceAvailableException('No read services were available');
  681. -
  682.             }
  683. -
  684.         }
  685. -
  686.  
  687. -
  688.         return $this->_readableServices[$this->_currentReadService];
  689. -
  690.     }
  691. -
  692.  
  693. -
  694.     /**
  695. -
  696.      * Iterate through available write services and select the first with a ping
  697. -
  698.      * that satisfies configured timeout restrictions (or the default)
  699. -
  700.      *
  701. -
  702.      * @return Apache_Solr_Service 
  703. -
  704.      *
  705. -
  706.      * @throws Apache_Solr_NoServiceAvailableException If there are no write services that meet requirements
  707. -
  708.      */
  709. -
  710.     protected function _selectWriteService($forceSelect false)
  711. -
  712.     {
  713. -
  714.         if($this->_useBackoff)
  715. -
  716.         {
  717. -
  718.             return $this->_selectWriteServiceSafe($forceSelect);
  719. -
  720.         }
  721. -
  722.  
  723. -
  724.         if (!$this->_currentWriteService || !isset($this->_writeableServices[$this->_currentWriteService]|| $forceSelect)
  725. -
  726.         {
  727. -
  728.             if ($this->_currentWriteService && isset($this->_writeableServices[$this->_currentWriteService]&& $forceSelect)
  729. -
  730.             {
  731. -
  732.                 // we probably had a communication error, ping the current read service, remove it if it times out
  733. -
  734.                 if ($this->_writeableServices[$this->_currentWriteService]->ping($this->_writePingTimeout=== false)
  735. -
  736.                 {
  737. -
  738.                     $this->removeWriteService($this->_currentWriteService);
  739. -
  740.                 }
  741. -
  742.             }
  743. -
  744.  
  745. -
  746.             if (count($this->_writeableServices))
  747. -
  748.             {
  749. -
  750.                 // select one of the read services at random
  751. -
  752.                 $ids array_keys($this->_writeableServices);
  753. -
  754.  
  755. -
  756.                 $id $ids[rand(0count($ids1)];
  757. -
  758.                 $service $this->_writeableServices[$id];
  759. -
  760.  
  761. -
  762.                 if (is_array($service))
  763. -
  764.                 {
  765. -
  766.                     //convert the array definition to a client object
  767. -
  768.                     $service new Apache_Solr_Service($service['host']$service['port']$service['path']);
  769. -
  770.                     $this->_writeableServices[$id$service;
  771. -
  772.                 }
  773. -
  774.  
  775. -
  776.                 $this->_currentWriteService = $id;
  777. -
  778.             }
  779. -
  780.             else
  781. -
  782.             {
  783. -
  784.                 throw new Apache_Solr_NoServiceAvailableException('No write services were available');
  785. -
  786.             }
  787. -
  788.         }
  789. -
  790.  
  791. -
  792.         return $this->_writeableServices[$this->_currentWriteService];
  793. -
  794.     }
  795. -
  796.  
  797. -
  798.     /**
  799. -
  800.      * Iterate through available write services and select the first with a ping
  801. -
  802.      * that satisfies configured timeout restrictions (or the default).  The
  803. -
  804.      * timeout period will increase until a connection is made or the limit is
  805. -
  806.      * reached.   This will allow for increased reliability with heavily loaded
  807. -
  808.      * server(s).
  809. -
  810.      *
  811. -
  812.      * @return Apache_Solr_Service 
  813. -
  814.      *
  815. -
  816.      * @throws Apache_Solr_NoServiceAvailableException If there are no write services that meet requirements
  817. -
  818.      */
  819. -
  820.  
  821. -
  822.     protected function _selectWriteServiceSafe($forceSelect false)
  823. -
  824.     {
  825. -
  826.         if (!$this->_currentWriteService || !isset($this->_writeableServices[$this->_currentWriteService]|| $forceSelect)
  827. -
  828.         {
  829. -
  830.             if (count($this->_writeableServices))
  831. -
  832.             {
  833. -
  834.                 $backoff $this->_defaultBackoff;
  835. -
  836.  
  837. -
  838.                 do {
  839. -
  840.                     // select one of the read services at random
  841. -
  842.                     $ids array_keys($this->_writeableServices);
  843. -
  844.  
  845. -
  846.                     $id $ids[rand(0count($ids1)];
  847. -
  848.                     $service $this->_writeableServices[$id];
  849. -
  850.  
  851. -
  852.                     if (is_array($service))
  853. -
  854.                     {
  855. -
  856.                         //convert the array definition to a client object
  857. -
  858.                         $service new Apache_Solr_Service($service['host']$service['port']$service['path']);
  859. -
  860.                         $this->_writeableServices[$id$service;
  861. -
  862.                     }
  863. -
  864.  
  865. -
  866.                     $this->_currentWriteService = $id;
  867. -
  868.  
  869. -
  870.                     $backoff *= $this->_backoffEscalation;
  871. -
  872.  
  873. -
  874.                     if($backoff $this->_backoffLimit)
  875. -
  876.                     {
  877. -
  878.                         throw new Apache_Solr_NoServiceAvailableException('No write services were available.  All timeouts exceeded.');
  879. -
  880.                     }
  881. -
  882.  
  883. -
  884.                 while($this->_writeableServices[$this->_currentWriteService]->ping($backoff=== false);
  885. -
  886.             }
  887. -
  888.             else
  889. -
  890.             {
  891. -
  892.                 throw new Apache_Solr_NoServiceAvailableException('No write services were available');
  893. -
  894.             }
  895. -
  896.         }
  897. -
  898.  
  899. -
  900.         return $this->_writeableServices[$this->_currentWriteService];
  901. -
  902.     }
  903. -
  904.  
  905. -
  906.     /**
  907. -
  908.      * Set the create documents flag. This determines whether {@link Apache_Solr_Response} objects will
  909. -
  910.      * parse the response and create {@link Apache_Solr_Document} instances in place.
  911. -
  912.      *
  913. -
  914.      * @param boolean $createDocuments 
  915. -
  916.      */
  917. -
  918.     public function setCreateDocuments($createDocuments)
  919. -
  920.     {
  921. -
  922.         $this->_createDocuments = (bool) $createDocuments;
  923. -
  924.  
  925. -
  926.         // set on current read service
  927. -
  928.         if ($this->_currentReadService)
  929. -
  930.         {
  931. -
  932.             $service $this->_selectReadService();
  933. -
  934.             $service->setCreateDocuments($createDocuments);
  935. -
  936.         }
  937. -
  938.     }
  939. -
  940.  
  941. -
  942.     /**
  943. -
  944.      * Get the current state of teh create documents flag.
  945. -
  946.      *
  947. -
  948.      * @return boolean 
  949. -
  950.      */
  951. -
  952.     public function getCreateDocuments()
  953. -
  954.     {
  955. -
  956.         return $this->_createDocuments;
  957. -
  958.     }
  959. -
  960.     
  961. -
  962.     /**
  963. -
  964.      * Raw Add Method. Takes a raw post body and sends it to the update service.  Post body
  965. -
  966.      * should be a complete and well formed "add" xml document.
  967. -
  968.      *
  969. -
  970.      * @param string $rawPost 
  971. -
  972.      * @return Apache_Solr_Response 
  973. -
  974.      *
  975. -
  976.      * @throws Apache_Solr_HttpTransportException If an error occurs during the service call
  977. -
  978.      */
  979. -
  980.     public function add($rawPost)
  981. -
  982.     {
  983. -
  984.         $service $this->_selectWriteService();
  985. -
  986.  
  987. -
  988.         do
  989. -
  990.         {
  991. -
  992.             try
  993. -
  994.             {
  995. -
  996.                 return $service->add($rawPost);
  997. -
  998.             }
  999. -
  1000.             catch (Apache_Solr_HttpTransportException $e)
  1001. -
  1002.             {
  1003. -
  1004.                 if ($e->getCode(!= 0//IF NOT COMMUNICATION ERROR
  1005. -
  1006.                 {
  1007. -
  1008.                     throw $e;
  1009. -
  1010.                 }
  1011. -
  1012.             }
  1013. -
  1014.  
  1015. -
  1016.             $service $this->_selectWriteService(true);
  1017. -
  1018.         while ($service);
  1019. -
  1020.  
  1021. -
  1022.         return false;
  1023. -
  1024.     }
  1025. -
  1026.  
  1027. -
  1028.     /**
  1029. -
  1030.      * Add a Solr Document to the index
  1031. -
  1032.      *
  1033. -
  1034.      * @param Apache_Solr_Document $document 
  1035. -
  1036.      * @param boolean $allowDups 
  1037. -
  1038.      * @param boolean $overwritePending 
  1039. -
  1040.      * @param boolean $overwriteCommitted 
  1041. -
  1042.      * @return Apache_Solr_Response 
  1043. -
  1044.      *
  1045. -
  1046.      * @throws Apache_Solr_HttpTransportException If an error occurs during the service call
  1047. -
  1048.      */
  1049. -
  1050.     public function addDocument(Apache_Solr_Document $document$allowDups false$overwritePending true$overwriteCommitted true)
  1051. -
  1052.     {
  1053. -
  1054.         $service $this->_selectWriteService();
  1055. -
  1056.  
  1057. -
  1058.         do
  1059. -
  1060.         {
  1061. -
  1062.             try
  1063. -
  1064.             {
  1065. -
  1066.                 return $service->addDocument($document$allowDups$overwritePending$overwriteCommitted);
  1067. -
  1068.             }
  1069. -
  1070.             catch (Apache_Solr_HttpTransportException $e)
  1071. -
  1072.             {
  1073. -
  1074.                 if ($e->getCode(!= 0//IF NOT COMMUNICATION ERROR
  1075. -
  1076.                 {
  1077. -
  1078.                     throw $e;
  1079. -
  1080.                 }
  1081. -
  1082.             }
  1083. -
  1084.  
  1085. -
  1086.             $service $this->_selectWriteService(true);
  1087. -
  1088.         while ($service);
  1089. -
  1090.  
  1091. -
  1092.         return false;
  1093. -
  1094.     }
  1095. -
  1096.  
  1097. -
  1098.     /**
  1099. -
  1100.      * Add an array of Solr Documents to the index all at once
  1101. -
  1102.      *
  1103. -
  1104.      * @param array $documents Should be an array of Apache_Solr_Document instances
  1105. -
  1106.      * @param boolean $allowDups 
  1107. -
  1108.      * @param boolean $overwritePending 
  1109. -
  1110.      * @param boolean $overwriteCommitted 
  1111. -
  1112.      * @return Apache_Solr_Response 
  1113. -
  1114.      *
  1115. -
  1116.      * @throws Apache_Solr_HttpTransportException If an error occurs during the service call
  1117. -
  1118.      */
  1119. -
  1120.     public function addDocuments($documents$allowDups false$overwritePending true$overwriteCommitted true)
  1121. -
  1122.     {
  1123. -
  1124.         $service $this->_selectWriteService();
  1125. -
  1126.  
  1127. -
  1128.         do
  1129. -
  1130.         {
  1131. -
  1132.             try
  1133. -
  1134.             {
  1135. -
  1136.                 return $service->addDocuments($documents$allowDups$overwritePending$overwriteCommitted);
  1137. -
  1138.             }
  1139. -
  1140.             catch (Apache_Solr_HttpTransportException $e)
  1141. -
  1142.             {
  1143. -
  1144.                 if ($e->getCode(!= 0//IF NOT COMMUNICATION ERROR
  1145. -
  1146.                 {
  1147. -
  1148.                     throw $e;
  1149. -
  1150.                 }
  1151. -
  1152.             }
  1153. -
  1154.  
  1155. -
  1156.             $service $this->_selectWriteService(true);
  1157. -
  1158.         while ($service);
  1159. -
  1160.  
  1161. -
  1162.         return false;
  1163. -
  1164.     }
  1165. -
  1166.  
  1167. -
  1168.     /**
  1169. -
  1170.      * Send a commit command.  Will be synchronous unless both wait parameters are set
  1171. -
  1172.      * to false.
  1173. -
  1174.      *
  1175. -
  1176.      * @param boolean $waitFlush 
  1177. -
  1178.      * @param boolean $waitSearcher 
  1179. -
  1180.      * @return Apache_Solr_Response 
  1181. -
  1182.      *
  1183. -
  1184.      * @throws Apache_Solr_HttpTransportException If an error occurs during the service call
  1185. -
  1186.      */
  1187. -
  1188.     public function commit($optimize true$waitFlush true$waitSearcher true$timeout 3600)
  1189. -
  1190.     {
  1191. -
  1192.         $service $this->_selectWriteService();
  1193. -
  1194.  
  1195. -
  1196.         do
  1197. -
  1198.         {
  1199. -
  1200.             try
  1201. -
  1202.             {
  1203. -
  1204.                 return $service->commit($optimize$waitFlush$waitSearcher$timeout);
  1205. -
  1206.             }
  1207. -
  1208.             catch (Apache_Solr_HttpTransportException $e)
  1209. -
  1210.             {
  1211. -
  1212.                 if ($e->getCode(!= 0//IF NOT COMMUNICATION ERROR
  1213. -
  1214.                 {
  1215. -
  1216.                     throw $e;
  1217. -
  1218.                 }
  1219. -
  1220.             }
  1221. -
  1222.  
  1223. -
  1224.             $service $this->_selectWriteService(true);
  1225. -
  1226.         while ($service);
  1227. -
  1228.  
  1229. -
  1230.         return false;
  1231. -
  1232.     }
  1233. -
  1234.  
  1235. -
  1236.     /**
  1237. -
  1238.      * Raw Delete Method. Takes a raw post body and sends it to the update service. Body should be
  1239. -
  1240.      * a complete and well formed "delete" xml document
  1241. -
  1242.      *
  1243. -
  1244.      * @param string $rawPost 
  1245. -
  1246.      * @param float $timeout Maximum expected duration of the delete operation on the server (otherwise, will throw a communication exception)
  1247. -
  1248.      * @return Apache_Solr_Response 
  1249. -
  1250.      *
  1251. -
  1252.      * @throws Apache_Solr_HttpTransportException If an error occurs during the service call
  1253. -
  1254.      */
  1255. -
  1256.     public function delete($rawPost$timeout 3600)
  1257. -
  1258.     {
  1259. -
  1260.         $service $this->_selectWriteService();
  1261. -
  1262.  
  1263. -
  1264.         do
  1265. -
  1266.         {
  1267. -
  1268.             try
  1269. -
  1270.             {
  1271. -
  1272.                 return $service->delete($rawPost$timeout);
  1273. -
  1274.             }
  1275. -
  1276.             catch (Apache_Solr_HttpTransportException $e)
  1277. -
  1278.             {
  1279. -
  1280.                 if ($e->getCode(!= 0//IF NOT COMMUNICATION ERROR
  1281. -
  1282.                 {
  1283. -
  1284.                     throw $e;
  1285. -
  1286.                 }
  1287. -
  1288.             }
  1289. -
  1290.  
  1291. -
  1292.             $service $this->_selectWriteService(true);
  1293. -
  1294.         while ($service);
  1295. -
  1296.  
  1297. -
  1298.         return false;
  1299. -
  1300.     }
  1301. -
  1302.  
  1303. -
  1304.     /**
  1305. -
  1306.      * Create a delete document based on document ID
  1307. -
  1308.      *
  1309. -
  1310.      * @param string $id 
  1311. -
  1312.      * @param boolean $fromPending 
  1313. -
  1314.      * @param boolean $fromCommitted 
  1315. -
  1316.      * @param float $timeout Maximum expected duration of the delete operation on the server (otherwise, will throw a communication exception)
  1317. -
  1318.      * @return Apache_Solr_Response 
  1319. -
  1320.      *
  1321. -
  1322.      * @throws Apache_Solr_HttpTransportException If an error occurs during the service call
  1323. -
  1324.      */
  1325. -
  1326.     public function deleteById($id$fromPending true$fromCommitted true$timeout 3600)
  1327. -
  1328.     {
  1329. -
  1330.         $service $this->_selectWriteService();
  1331. -
  1332.  
  1333. -
  1334.         do
  1335. -
  1336.         {
  1337. -
  1338.             try
  1339. -
  1340.             {
  1341. -
  1342.                 return $service->deleteById($id$fromPending$fromCommitted$timeout);
  1343. -
  1344.             }
  1345. -
  1346.             catch (Apache_Solr_HttpTransportException $e)
  1347. -
  1348.             {
  1349. -
  1350.                 if ($e->getCode(!= 0//IF NOT COMMUNICATION ERROR
  1351. -
  1352.                 {
  1353. -
  1354.                     throw $e;
  1355. -
  1356.                 }
  1357. -
  1358.             }
  1359. -
  1360.  
  1361. -
  1362.             $service $this->_selectWriteService(true);
  1363. -
  1364.         while ($service);
  1365. -
  1366.  
  1367. -
  1368.         return false;
  1369. -
  1370.     }
  1371. -
  1372.  
  1373. -
  1374.     /**
  1375. -
  1376.      * Create and post a delete document based on multiple document IDs.
  1377. -
  1378.      *
  1379. -
  1380.      * @param array $ids Expected to be utf-8 encoded strings
  1381. -
  1382.      * @param boolean $fromPending 
  1383. -
  1384.      * @param boolean $fromCommitted 
  1385. -
  1386.      * @param float $timeout Maximum expected duration of the delete operation on the server (otherwise, will throw a communication exception)
  1387. -
  1388.      * @return Apache_Solr_Response 
  1389. -
  1390.      *
  1391. -
  1392.      * @throws Apache_Solr_HttpTransportException If an error occurs during the service call
  1393. -
  1394.      */
  1395. -
  1396.     public function deleteByMultipleIds($ids$fromPending true$fromCommitted true$timeout 3600)
  1397. -
  1398.     {
  1399. -
  1400.         $service $this->_selectWriteService();
  1401. -
  1402.  
  1403. -
  1404.         do
  1405. -
  1406.         {
  1407. -
  1408.             try
  1409. -
  1410.             {
  1411. -
  1412.                 return $service->deleteByMultipleId($ids$fromPending$fromCommitted$timeout);
  1413. -
  1414.             }
  1415. -
  1416.             catch (Apache_Solr_HttpTransportException $e)
  1417. -
  1418.             {
  1419. -
  1420.                 if ($e->getCode(!= 0//IF NOT COMMUNICATION ERROR
  1421. -
  1422.                 {
  1423. -
  1424.                     throw $e;
  1425. -
  1426.                 }
  1427. -
  1428.             }
  1429. -
  1430.  
  1431. -
  1432.             $service $this->_selectWriteService(true);
  1433. -
  1434.         while ($service);
  1435. -
  1436.  
  1437. -
  1438.         return false;
  1439. -
  1440.     }
  1441. -
  1442.  
  1443. -
  1444.     /**
  1445. -
  1446.      * Create a delete document based on a query and submit it
  1447. -
  1448.      *
  1449. -
  1450.      * @param string $rawQuery 
  1451. -
  1452.      * @param boolean $fromPending 
  1453. -
  1454.      * @param boolean $fromCommitted 
  1455. -
  1456.      * @param float $timeout Maximum expected duration of the delete operation on the server (otherwise, will throw a communication exception)
  1457. -
  1458.      * @return Apache_Solr_Response 
  1459. -
  1460.      *
  1461. -
  1462.      * @throws Apache_Solr_HttpTransportException If an error occurs during the service call
  1463. -
  1464.      */
  1465. -
  1466.     public function deleteByQuery($rawQuery$fromPending true$fromCommitted true$timeout 3600)
  1467. -
  1468.     {
  1469. -
  1470.         $service $this->_selectWriteService();
  1471. -
  1472.  
  1473. -
  1474.         do
  1475. -
  1476.         {
  1477. -
  1478.             try
  1479. -
  1480.             {
  1481. -
  1482.                 return $service->deleteByQuery($rawQuery$fromPending$fromCommitted$timeout);
  1483. -
  1484.             }
  1485. -
  1486.             catch (Apache_Solr_HttpTransportException $e)
  1487. -
  1488.             {
  1489. -
  1490.                 if ($e->getCode(!= 0//IF NOT COMMUNICATION ERROR
  1491. -
  1492.                 {
  1493. -
  1494.                     throw $e;
  1495. -
  1496.                 }
  1497. -
  1498.             }
  1499. -
  1500.  
  1501. -
  1502.             $service $this->_selectWriteService(true);
  1503. -
  1504.         while ($service);
  1505. -
  1506.  
  1507. -
  1508.         return false;
  1509. -
  1510.     }
  1511. -
  1512.     
  1513. -
  1514.     /**
  1515. -
  1516.      * Use Solr Cell to extract document contents. See {@link http://wiki.apache.org/solr/ExtractingRequestHandler} for information on how
  1517. -
  1518.      * to use Solr Cell and what parameters are available.
  1519. -
  1520.      *
  1521. -
  1522.      * NOTE: when passing an Apache_Solr_Document instance, field names and boosts will automatically be prepended by "literal." and "boost."
  1523. -
  1524.      * as appropriate. Any keys from the $params array will NOT be treated this way. Any mappings from the document will overwrite key / value
  1525. -
  1526.      * pairs in the params array if they have the same name (e.g. you pass a "literal.id" key and value in your $params array but you also
  1527. -
  1528.      * pass in a document isntance with an "id" field" - the document's value(s) will take precedence).
  1529. -
  1530.      *
  1531. -
  1532.      * @param string $file Path to file to extract data from
  1533. -
  1534.      * @param array $params optional array of key value pairs that will be sent with the post (see Solr Cell documentation)
  1535. -
  1536.      * @param Apache_Solr_Document $document optional document that will be used to generate post parameters (literal.* and boost.* params)
  1537. -
  1538.      * @param string $mimetype optional mimetype specification (for the file being extracted)
  1539. -
  1540.      *
  1541. -
  1542.      * @return Apache_Solr_Response 
  1543. -
  1544.      *
  1545. -
  1546.      * @throws Apache_Solr_InvalidArgumentException if $file, $params, or $document are invalid.
  1547. -
  1548.      */
  1549. -
  1550.     public function extract($file$params array()$document null$mimetype 'application/octet-stream')
  1551. -
  1552.     {
  1553. -
  1554.         $service $this->_selectWriteService();
  1555. -
  1556.  
  1557. -
  1558.         do
  1559. -
  1560.         {
  1561. -
  1562.             try
  1563. -
  1564.             {
  1565. -
  1566.                 return $service->extract($file$params$document$mimetype);
  1567. -
  1568.             }
  1569. -
  1570.             catch (Apache_Solr_HttpTransportException $e)
  1571. -
  1572.             {
  1573. -
  1574.                 if ($e->getCode(!= 0//IF NOT COMMUNICATION ERROR
  1575. -
  1576.                 {
  1577. -
  1578.                     throw $e;
  1579. -
  1580.                 }
  1581. -
  1582.             }
  1583. -
  1584.  
  1585. -
  1586.             $service $this->_selectWriteService(true);
  1587. -
  1588.         while ($service);
  1589. -
  1590.  
  1591. -
  1592.         return false;
  1593. -
  1594.     }
  1595. -
  1596.     
  1597. -
  1598.     /**
  1599. -
  1600.      * Use Solr Cell to extract document contents. See {@link http://wiki.apache.org/solr/ExtractingRequestHandler} for information on how
  1601. -
  1602.      * to use Solr Cell and what parameters are available.
  1603. -
  1604.      *
  1605. -
  1606.      * NOTE: when passing an Apache_Solr_Document instance, field names and boosts will automatically be prepended by "literal." and "boost."
  1607. -
  1608.      * as appropriate. Any keys from the $params array will NOT be treated this way. Any mappings from the document will overwrite key / value
  1609. -
  1610.      * pairs in the params array if they have the same name (e.g. you pass a "literal.id" key and value in your $params array but you also
  1611. -
  1612.      * pass in a document isntance with an "id" field" - the document's value(s) will take precedence).
  1613. -
  1614.      *
  1615. -
  1616.      * @param string $data Data that will be passed to Solr Cell
  1617. -
  1618.      * @param array $params optional array of key value pairs that will be sent with the post (see Solr Cell documentation)
  1619. -
  1620.      * @param Apache_Solr_Document $document optional document that will be used to generate post parameters (literal.* and boost.* params)
  1621. -
  1622.      * @param string $mimetype optional mimetype specification (for the file being extracted)
  1623. -
  1624.      *
  1625. -
  1626.      * @return Apache_Solr_Response 
  1627. -
  1628.      *
  1629. -
  1630.      * @throws Apache_Solr_InvalidArgumentException if $file, $params, or $document are invalid.
  1631. -
  1632.      *
  1633. -
  1634.      * @todo Should be using multipart/form-data to post parameter values, but I could not get my implementation to work. Needs revisisted.
  1635. -
  1636.      */
  1637. -
  1638.     public function extractFromString($data$params array()$document null$mimetype 'application/octet-stream')
  1639. -
  1640.     {
  1641. -
  1642.         $service $this->_selectWriteService();
  1643. -
  1644.  
  1645. -
  1646.         do
  1647. -
  1648.         {
  1649. -
  1650.             try
  1651. -
  1652.             {
  1653. -
  1654.                 return $service->extractFromString($data$params$document$mimetype);
  1655. -
  1656.             }
  1657. -
  1658.             catch (Apache_Solr_HttpTransportException $e)
  1659. -
  1660.             {
  1661. -
  1662.                 if ($e->getCode(!= 0//IF NOT COMMUNICATION ERROR
  1663. -
  1664.                 {
  1665. -
  1666.                     throw $e;
  1667. -
  1668.                 }
  1669. -
  1670.             }
  1671. -
  1672.  
  1673. -
  1674.             $service $this->_selectWriteService(true);
  1675. -
  1676.         while ($service);
  1677. -
  1678.  
  1679. -
  1680.         return false;
  1681. -
  1682.     }
  1683. -
  1684.     
  1685. -
  1686.     /**
  1687. -
  1688.      * Send an optimize command.  Will be synchronous unless both wait parameters are set
  1689. -
  1690.      * to false.
  1691. -
  1692.      *
  1693. -
  1694.      * @param boolean $waitFlush 
  1695. -
  1696.      * @param boolean $waitSearcher 
  1697. -
  1698.      * @param float $timeout Maximum expected duration of the optimize operation on the server (otherwise, will throw a communication exception)
  1699. -
  1700.      * @return Apache_Solr_Response 
  1701. -
  1702.      *
  1703. -
  1704.      * @throws Apache_Solr_HttpTransportException If an error occurs during the service call
  1705. -
  1706.      */
  1707. -
  1708.     public function optimize($waitFlush true$waitSearcher true$timeout 3600)
  1709. -
  1710.     {
  1711. -
  1712.         $service $this->_selectWriteService();
  1713. -
  1714.  
  1715. -
  1716.         do
  1717. -
  1718.         {
  1719. -
  1720.             try
  1721. -
  1722.             {
  1723. -
  1724.                 return $service->optimize($waitFlush$waitSearcher$timeout);
  1725. -
  1726.             }
  1727. -
  1728.             catch (Apache_Solr_HttpTransportException $e)
  1729. -
  1730.             {
  1731. -
  1732.                 if ($e->getCode(!= 0//IF NOT COMMUNICATION ERROR
  1733. -
  1734.                 {
  1735. -
  1736.                     throw $e;
  1737. -
  1738.                 }
  1739. -
  1740.             }
  1741. -
  1742.  
  1743. -
  1744.             $service $this->_selectWriteService(true);
  1745. -
  1746.         while ($service);
  1747. -
  1748.  
  1749. -
  1750.         return false;
  1751. -
  1752.     }
  1753. -
  1754.  
  1755. -
  1756.     /**
  1757. -
  1758.      * Simple Search interface
  1759. -
  1760.      *
  1761. -
  1762.      * @param string $query The raw query string
  1763. -
  1764.      * @param int $offset The starting offset for result documents
  1765. -
  1766.      * @param int $limit The maximum number of result documents to return
  1767. -
  1768.      * @param array $params key / value pairs for query parameters, use arrays for multivalued parameters
  1769. -
  1770.      * @param string $method The HTTP method (Apache_Solr_Service::METHOD_GET or Apache_Solr_Service::METHOD::POST)
  1771. -
  1772.      * @return Apache_Solr_Response 
  1773. -
  1774.      *
  1775. -
  1776.      * @throws Apache_Solr_HttpTransportException If an error occurs during the service call
  1777. -
  1778.      */
  1779. -
  1780.     public function search($query$offset 0$limit 10$params array()$method Apache_Solr_Service::METHOD_GET)
  1781. -
  1782.     {
  1783. -
  1784.         $service $this->_selectReadService();
  1785. -
  1786.  
  1787. -
  1788.         do
  1789. -
  1790.         {
  1791. -
  1792.             try
  1793. -
  1794.             {
  1795. -
  1796.                 return $service->search($query$offset$limit$params$method);
  1797. -
  1798.             }
  1799. -
  1800.             catch (Apache_Solr_HttpTransportException $e)
  1801. -
  1802.             {
  1803. -
  1804.                 if ($e->getCode(!= 0//IF NOT COMMUNICATION ERROR
  1805. -
  1806.                 {
  1807. -
  1808.                     throw $e;
  1809. -
  1810.                 }
  1811. -
  1812.             }
  1813. -
  1814.  
  1815. -
  1816.             $service $this->_selectReadService(true);
  1817. -
  1818.         while ($service);
  1819. -
  1820.  
  1821. -
  1822.         return false;
  1823. -
  1824.     }
  1825. -
  1826. }
  1827. -
-
-

- Documentation generated on Wed, 04 May 2011 11:01:10 -0400 by phpDocumentor 1.4.3 -

- - \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/blank.html b/SolrPhpClient/phpdocs/blank.html deleted file mode 100644 index 38517691..00000000 --- a/SolrPhpClient/phpdocs/blank.html +++ /dev/null @@ -1,13 +0,0 @@ - - - Generated Documentation - - - - -

Generated Documentation

-Welcome to Apache!
-
-This documentation was generated by phpDocumentor v1.4.3
- - \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/classtrees_Apache.html b/SolrPhpClient/phpdocs/classtrees_Apache.html deleted file mode 100644 index e82831d9..00000000 --- a/SolrPhpClient/phpdocs/classtrees_Apache.html +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - -

- -

-

Root interface Apache_Solr_HttpTransport_Interface

- - -

Root class Apache_Solr_Document

- - -

Root class Apache_Solr_HttpTransport_Abstract

- - -

Root class Apache_Solr_HttpTransport_Response

- - -

Root class Apache_Solr_Response

- - -

Root class Apache_Solr_Service

- - -

Root class Apache_Solr_Service_Balancer

- - -

Root class Exception

- - -

- Documentation generated on Wed, 04 May 2011 11:01:08 -0400 by phpDocumentor 1.4.3 -

- - \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/elementindex.html b/SolrPhpClient/phpdocs/elementindex.html deleted file mode 100644 index 78d0581a..00000000 --- a/SolrPhpClient/phpdocs/elementindex.html +++ /dev/null @@ -1,1726 +0,0 @@ - - - - - - - - - - - -

Full index

-

Package indexes

- -
-
- a - b - c - d - e - f - g - h - i - m - n - o - p - r - s - t - u - _ -
- - -
-
a
- -
-
-
-
- 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
-
-
- addField -
-
- -
Add a value to a multi-valued field
-
-
- 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 along with any associated boost values. Field values can be accessed by direct dereferencing such as:
-
-
- Apache_Solr_Exception -
-
-
Apache_Solr_Exception in Exception.php
-
Copyright (c) 2007-2011, Servigistics, Inc.
-
-
- Apache_Solr_HttpTransportException -
-
-
Apache_Solr_HttpTransportException in HttpTransportException.php
-
Copyright (c) 2007-2011, Servigistics, Inc.
-
-
- Apache_Solr_HttpTransport_Abstract -
-
- -
Convenience class that implements the transport implementation. Can be extended by
-
-
- Apache_Solr_HttpTransport_Curl -
-
- -
A Curl based HTTP transport. Uses a single curl session for all requests.
-
-
- Apache_Solr_HttpTransport_CurlNoReuse -
-
- -
An alternative Curl HTTP transport that opens and closes a curl session for every request. This isn't the recommended way to use curl, but some version of PHP have memory issues.
-
-
- Apache_Solr_HttpTransport_FileGetContents -
-
- -
HTTP Transport implemenation that uses the builtin http URL wrappers and file_get_contents
-
-
- Apache_Solr_HttpTransport_Interface -
-
- -
Interface that all Transport (HTTP Requester) implementations must implement. These
-
-
- Apache_Solr_HttpTransport_Response -
-
- -
Represents the required pieces of an HTTP response provided by HTTP transport
-
-
- Apache_Solr_InvalidArgumentException -
-
-
Apache_Solr_InvalidArgumentException in InvalidArgumentException.php
-
Copyright (c) 2007-2011, Servigistics, Inc.
-
-
- Apache_Solr_NoServiceAvailableException -
-
-
Apache_Solr_NoServiceAvailableException in NoServiceAvailableException.php
-
Copyright (c) 2007-2011, Servigistics, Inc.
-
-
- Apache_Solr_ParserException -
-
-
Apache_Solr_ParserException in ParserException.php
-
Copyright (c) 2007-2011, Servigistics, Inc.
-
-
- 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
-
-
- Abstract.php -
-
-
Abstract.php in Abstract.php
-
-
- -
-
b
- -
-
-
-
- Balancer.php -
-
-
Balancer.php in Balancer.php
-
-
- -
-
c
- -
-
-
-
- clear -
-
- -
Clear all boosts and fields from this document
-
-
- 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.
-
-
- Curl.php -
-
-
Curl.php in Curl.php
-
-
- CurlNoReuse.php -
-
-
CurlNoReuse.php in CurlNoReuse.php
-
-
- -
-
d
- -
-
-
-
- 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
-
-
- deleteByMultipleIds -
-
- -
Create and post a delete document based on multiple document IDs.
-
-
- deleteByMultipleIds -
-
- -
Create and post a delete document based on multiple document IDs.
-
-
- 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
- -
-
-
-
- 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
-
-
- Exception.php -
-
-
Exception.php in Exception.php
-
-
- extract -
-
- -
Use Solr Cell to extract document contents. See http://wiki.apache.org/solr/ExtractingRequestHandler for information on how to use Solr Cell and what parameters are available.
-
-
- extract -
-
- -
Use Solr Cell to extract document contents. See http://wiki.apache.org/solr/ExtractingRequestHandler for information on how to use Solr Cell and what parameters are available.
-
-
- extractFromString -
-
- -
Use Solr Cell to extract document contents. See http://wiki.apache.org/solr/ExtractingRequestHandler for information on how to use Solr Cell and what parameters are available.
-
-
- extractFromString -
-
- -
Use Solr Cell to extract document contents. See http://wiki.apache.org/solr/ExtractingRequestHandler for information on how to use Solr Cell and what parameters are available.
-
-
- extractFromUrl -
-
- -
Use Solr Cell to extract document contents. See http://wiki.apache.org/solr/ExtractingRequestHandler for information on how to use Solr Cell and what parameters are available.
-
-
- EXTRACT_SERVLET -
-
- -
-
- -
-
f
- -
-
-
-
- FileGetContents.php -
-
-
FileGetContents.php in FileGetContents.php
-
-
- -
-
g
- -
-
-
-
- getBody -
-
- -
Get the raw response body
-
-
- getBoost -
-
- -
Get current document boost
-
-
- getCollapseSingleValueArrays -
-
- -
Get the current state of the collapse single value arrays flag.
-
-
- getCreateDocuments -
-
- -
Get the current state of teh create documents flag.
-
-
- getCreateDocuments -
-
- -
Get the current state of teh create documents flag.
-
-
- getDefaultStatusMessage -
-
- -
Get the HTTP status message based on status code
-
-
- getDefaultTimeout -
-
- -
Get the current default timeout setting (initially the default_socket_timeout ini setting) in seconds
-
-
- getDefaultTimeout -
-
- -
Get the current default timeout for all HTTP requests
-
-
- getDefaultTimeout -
-
- -
Get the current default timeout setting (initially the default_socket_timeout ini setting) in seconds
-
-
- getEncoding -
-
- -
Get the charset encoding of the response body.
-
-
- getEncoding -
-
- -
Get character encoding of this response. Should usually be utf-8, but just in case
-
-
- getField -
-
- -
Get field information
-
-
- getFieldBoost -
-
- -
Get the currently set field boost for a document field
-
-
- getFieldBoosts -
-
- -
Return current field boosts, indexed by field name
-
-
- getFieldNames -
-
- -
Get the names of all fields in this document
-
-
- getFieldValues -
-
- -
Get the values 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
-
-
- getHttpTransport -
-
- -
Get the current configured HTTP Transport
-
-
- getIterator -
-
- -
IteratorAggregate implementation function. Allows usage:
-
-
- getMimeType -
-
- -
Get the mimetype of the response body
-
-
- 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
-
-
- getResponse -
-
- -
Get the response for which this exception was generated
-
-
- getStatusCode -
-
- -
Get the status code of the response
-
-
- getStatusMessage -
-
- -
Get the status message of the response
-
-
- getType -
-
- -
Get content type of this Solr response
-
-
- -
-
h
- -
-
-
-
- HttpTransportException.php -
-
-
HttpTransportException.php in HttpTransportException.php
-
-
- -
-
i
- -
-
-
-
- Interface.php -
-
-
Interface.php in Interface.php
-
-
- InvalidArgumentException.php -
-
-
InvalidArgumentException.php in InvalidArgumentException.php
-
-
- -
-
m
- -
-
-
-
- METHOD_GET -
-
- -
Search HTTP Methods
-
-
- METHOD_POST -
-
- -
-
- -
-
n
- -
-
-
-
- NAMED_LIST_FLAT -
-
- -
NamedList Treatment constants
-
-
- NAMED_LIST_MAP -
-
- -
-
- NoServiceAvailableException.php -
-
-
NoServiceAvailableException.php in NoServiceAvailableException.php
-
-
- -
-
o
- -
-
-
-
- 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
- -
-
-
-
- ParserException.php -
-
-
ParserException.php in ParserException.php
-
-
- performGetRequest -
-
- -
-
- performGetRequest -
-
- -
-
- performGetRequest -
-
- -
-
- performGetRequest -
-
- -
Perform a GET HTTP operation with an optional timeout and return the response contents, use getLastResponseHeaders to retrieve HTTP headers
-
-
- performHeadRequest -
-
- -
Perform a HEAD HTTP operation with an optional timeout and return the response headers - NOTE: head requests have no response body
-
-
- performHeadRequest -
-
- -
-
- performHeadRequest -
-
- -
-
- performHeadRequest -
-
- -
-
- performPostRequest -
-
- -
-
- performPostRequest -
-
- -
Perform a POST HTTP operation with an optional timeout and return the response contents, use getLastResponseHeaders to retrieve HTTP headers
-
-
- performPostRequest -
-
- -
-
- performPostRequest -
-
- -
-
- 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
- -
-
-
-
- Response.php -
-
-
Response.php in Response.php
-
-
- 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
-
-
- -
-
s
- -
-
-
-
- search -
-
- -
Simple Search interface
-
-
- search -
-
- -
Simple Search interface
-
-
- SEARCH_SERVLET -
-
- -
-
- Service.php -
-
-
Service.php in Service.php
-
-
- setBoost -
-
- -
Set document boost factor
-
-
- 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 -
-
- -
Set the create documents flag. This determines whether Apache_Solr_Response objects will parse the response and create Apache_Solr_Document instances in place.
-
-
- setDefaultTimeout -
-
- -
Set the current default timeout for all HTTP requests
-
-
- setDefaultTimeout -
-
- -
Set the default timeout for all calls that aren't passed a specific timeout
-
-
- setDefaultTimeout -
-
- -
Set the current default timeout for all HTTP requests
-
-
- setField -
-
- -
Set a field value. Multi-valued fields should be set as arrays or instead use the addField(...) function which will automatically make sure the field is an array.
-
-
- setFieldBoost -
-
- -
Set the field boost for a document field
-
-
- setHost -
-
- -
Set the host used. If empty will fallback to constants
-
-
- setHttpTransport -
-
- -
Set the HTTP Transport implemenation that will be used for all HTTP requests
-
-
- setMultiValue -
-
- -
Handle the array manipulation for a multi-valued field
-
-
- setNamedListTreatment -
-
- -
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_WRITER -
-
- -
Response writer we'll request - JSON. See http://code.google.com/p/solr-php-client/issues/detail?id=6#c1 for reasoning
-
-
- SVN_ID -
-
- -
SVN ID meta data for this class
-
-
- SVN_ID -
-
- -
SVN ID meta data for this class
-
-
- SVN_ID -
-
- -
SVN ID meta data for this class
-
-
- SVN_ID -
-
- -
SVN ID meta data for this class
-
-
- SVN_ID -
-
- -
SVN ID meta data for this class
-
-
- SVN_ID -
-
-
Apache_Solr_InvalidArgumentException::SVN_ID in InvalidArgumentException.php
-
SVN ID meta data for this class
-
-
- SVN_ID -
-
- -
SVN ID meta data for this class
-
-
- SVN_ID -
-
-
Apache_Solr_HttpTransportException::SVN_ID in HttpTransportException.php
-
SVN ID meta data for this class
-
-
- SVN_ID -
-
- -
SVN ID meta data for this class
-
-
- SVN_ID -
-
-
Apache_Solr_NoServiceAvailableException::SVN_ID in NoServiceAvailableException.php
-
SVN ID meta data for this class
-
-
- SVN_ID -
-
- -
SVN ID meta data for this class
-
-
- SVN_ID -
-
- -
SVN ID meta data for this class
-
-
- SVN_REVISION -
-
- -
SVN Revision meta data for this class
-
-
- SVN_REVISION -
-
- -
SVN Revision meta data for this class
-
-
- SVN_REVISION -
-
- -
SVN Revision meta data for this class
-
-
- SVN_REVISION -
-
- -
SVN Revision meta data for this class
-
-
- SVN_REVISION -
-
- -
SVN Revision meta data for this class
-
-
- SVN_REVISION -
-
- -
SVN Revision meta data for this class
-
-
- SVN_REVISION -
-
- -
SVN Revision meta data for this class
-
-
- SVN_REVISION -
-
- -
SVN Revision meta data for this class
-
-
- SVN_REVISION -
-
- -
SVN Revision meta data for this class
-
-
- SVN_REVISION -
-
- -
SVN Revision meta data for this class
-
-
- SVN_REVISION -
-
- -
SVN Revision meta data for this class
-
-
- SVN_REVISION -
-
- -
SVN Revision meta data for this class
-
-
- -
-
t
- -
-
-
-
- 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
- -
-
-
-
- UPDATE_SERVLET -
-
- -
-
- -
-
_
- -
-
-
-
- $_backoffEscalation -
-
- -
-
- $_backoffLimit -
-
- -
-
- $_collapseSingleValueArrays -
-
- -
Whether Apache_Solr_Response objects should have multivalue fields with only a single value collapsed to appear as a single value would.
-
-
- $_collapseSingleValueArrays -
-
- -
-
- $_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
-
-
- $_createDocuments -
-
- -
-
- $_currentReadService -
-
- -
-
- $_currentWriteService -
-
- -
-
- $_defaultBackoff -
-
- -
-
- $_documentBoost -
-
- -
Document boost value
-
-
- $_fieldBoosts -
-
- -
Document field boost values, indexed by name
-
-
- $_fields -
-
- -
Document field values, indexed by name
-
-
- $_host -
-
- -
Server identification strings
-
-
- $_httpTransport -
-
- -
HTTP Transport implementation (pluggable)
-
-
- $_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 -
-
- -
-
- $_pingUrl -
-
- -
Constructed servlet full path URLs
-
-
- $_port -
-
- -
-
- $_queryBracketsEscaped -
-
- -
-
- $_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 -
-
- -
-
- $_readableServices -
-
- -
-
- $_readPingTimeout -
-
- -
-
- $_response -
-
- -
Holds the raw response used in construction
-
-
- $_searchUrl -
-
- -
-
- $_threadsUrl -
-
- -
-
- $_updateUrl -
-
- -
-
- $_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
-
-
- _generateQueryString -
-
- -
-
- _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
-
-
- _stripCtrlChars -
-
- -
Replace control (non-printable) characters from string that are invalid to Solr's XML parser with a space.
-
-
- __construct -
-
- -
Constructor. All parameters are optional and will take on default values if not specified.
-
-
- __construct -
-
- -
Construct a HTTP transport response
-
-
- __construct -
-
- -
Initializes our reuseable get and post stream contexts
-
-
- __construct -
-
- -
Initializes a curl session
-
-
- __construct -
-
- -
HttpTransportException Constructor
-
-
- __construct -
-
- -
Constructor. Takes the raw HTTP response body and the exploded HTTP headers
-
-
- __construct -
-
- -
Constructor. Takes arrays of read and write service instances or descriptions
-
-
- __destruct -
-
- -
Closes a curl session
-
-
- __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 not call directly. Allows usage:
-
-
- __isset -
-
- -
Magic function for isset function on parsed data
-
-
- __set -
-
- -
Magic set for field values. Multi-valued fields should be set as arrays or instead use the addField(...) function which will automatically make sure the field is an array.
-
-
- __unset -
-
- -
Magic unset for field values. Do not call directly. Allows usage:
-
-
- -
- a - b - c - d - e - f - g - h - i - m - n - o - p - r - s - t - u - _ -
- \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/elementindex_Apache.html b/SolrPhpClient/phpdocs/elementindex_Apache.html deleted file mode 100644 index ae0fec6f..00000000 --- a/SolrPhpClient/phpdocs/elementindex_Apache.html +++ /dev/null @@ -1,1723 +0,0 @@ - - - - - - - - - - - -

[Apache] element index

-All elements -
-
- a - b - c - d - e - f - g - h - i - m - n - o - p - r - s - t - u - _ -
- - -
-
_
- -
-
-
-
- $_backoffEscalation -
-
- -
-
- $_backoffLimit -
-
- -
-
- $_collapseSingleValueArrays -
-
- -
Whether Apache_Solr_Response objects should have multivalue fields with only a single value collapsed to appear as a single value would.
-
-
- $_collapseSingleValueArrays -
-
- -
-
- $_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
-
-
- $_createDocuments -
-
- -
-
- $_currentReadService -
-
- -
-
- $_currentWriteService -
-
- -
-
- $_defaultBackoff -
-
- -
-
- $_documentBoost -
-
- -
Document boost value
-
-
- $_fieldBoosts -
-
- -
Document field boost values, indexed by name
-
-
- $_fields -
-
- -
Document field values, indexed by name
-
-
- $_host -
-
- -
Server identification strings
-
-
- $_httpTransport -
-
- -
HTTP Transport implementation (pluggable)
-
-
- $_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 -
-
- -
-
- $_pingUrl -
-
- -
Constructed servlet full path URLs
-
-
- $_port -
-
- -
-
- $_queryBracketsEscaped -
-
- -
-
- $_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 -
-
- -
-
- $_readableServices -
-
- -
-
- $_readPingTimeout -
-
- -
-
- $_response -
-
- -
Holds the raw response used in construction
-
-
- $_searchUrl -
-
- -
-
- $_threadsUrl -
-
- -
-
- $_updateUrl -
-
- -
-
- $_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
-
-
- _generateQueryString -
-
- -
-
- _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
-
-
- _stripCtrlChars -
-
- -
Replace control (non-printable) characters from string that are invalid to Solr's XML parser with a space.
-
-
- __construct -
-
- -
Constructor. All parameters are optional and will take on default values if not specified.
-
-
- __construct -
-
- -
Construct a HTTP transport response
-
-
- __construct -
-
- -
Initializes our reuseable get and post stream contexts
-
-
- __construct -
-
- -
Initializes a curl session
-
-
- __construct -
-
- -
HttpTransportException Constructor
-
-
- __construct -
-
- -
Constructor. Takes the raw HTTP response body and the exploded HTTP headers
-
-
- __construct -
-
- -
Constructor. Takes arrays of read and write service instances or descriptions
-
-
- __destruct -
-
- -
Closes a curl session
-
-
- __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 not call directly. Allows usage:
-
-
- __isset -
-
- -
Magic function for isset function on parsed data
-
-
- __set -
-
- -
Magic set for field values. Multi-valued fields should be set as arrays or instead use the addField(...) function which will automatically make sure the field is an array.
-
-
- __unset -
-
- -
Magic unset for field values. Do not call directly. Allows usage:
-
-
- -
-
a
- -
-
-
-
- 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
-
-
- addField -
-
- -
Add a value to a multi-valued field
-
-
- 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 along with any associated boost values. Field values can be accessed by direct dereferencing such as:
-
-
- Apache_Solr_Exception -
-
-
Apache_Solr_Exception in Exception.php
-
Copyright (c) 2007-2011, Servigistics, Inc.
-
-
- Apache_Solr_HttpTransportException -
-
-
Apache_Solr_HttpTransportException in HttpTransportException.php
-
Copyright (c) 2007-2011, Servigistics, Inc.
-
-
- Apache_Solr_HttpTransport_Abstract -
-
- -
Convenience class that implements the transport implementation. Can be extended by
-
-
- Apache_Solr_HttpTransport_Curl -
-
- -
A Curl based HTTP transport. Uses a single curl session for all requests.
-
-
- Apache_Solr_HttpTransport_CurlNoReuse -
-
- -
An alternative Curl HTTP transport that opens and closes a curl session for every request. This isn't the recommended way to use curl, but some version of PHP have memory issues.
-
-
- Apache_Solr_HttpTransport_FileGetContents -
-
- -
HTTP Transport implemenation that uses the builtin http URL wrappers and file_get_contents
-
-
- Apache_Solr_HttpTransport_Interface -
-
- -
Interface that all Transport (HTTP Requester) implementations must implement. These
-
-
- Apache_Solr_HttpTransport_Response -
-
- -
Represents the required pieces of an HTTP response provided by HTTP transport
-
-
- Apache_Solr_InvalidArgumentException -
-
-
Apache_Solr_InvalidArgumentException in InvalidArgumentException.php
-
Copyright (c) 2007-2011, Servigistics, Inc.
-
-
- Apache_Solr_NoServiceAvailableException -
-
-
Apache_Solr_NoServiceAvailableException in NoServiceAvailableException.php
-
Copyright (c) 2007-2011, Servigistics, Inc.
-
-
- Apache_Solr_ParserException -
-
-
Apache_Solr_ParserException in ParserException.php
-
Copyright (c) 2007-2011, Servigistics, Inc.
-
-
- 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
-
-
- Abstract.php -
-
-
Abstract.php in Abstract.php
-
-
- -
-
b
- -
-
-
-
- Balancer.php -
-
-
Balancer.php in Balancer.php
-
-
- -
-
c
- -
-
-
-
- clear -
-
- -
Clear all boosts and fields from this document
-
-
- 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.
-
-
- Curl.php -
-
-
Curl.php in Curl.php
-
-
- CurlNoReuse.php -
-
-
CurlNoReuse.php in CurlNoReuse.php
-
-
- -
-
d
- -
-
-
-
- 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
-
-
- deleteByMultipleIds -
-
- -
Create and post a delete document based on multiple document IDs.
-
-
- deleteByMultipleIds -
-
- -
Create and post a delete document based on multiple document IDs.
-
-
- 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
- -
-
-
-
- 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
-
-
- Exception.php -
-
-
Exception.php in Exception.php
-
-
- extract -
-
- -
Use Solr Cell to extract document contents. See http://wiki.apache.org/solr/ExtractingRequestHandler for information on how to use Solr Cell and what parameters are available.
-
-
- extract -
-
- -
Use Solr Cell to extract document contents. See http://wiki.apache.org/solr/ExtractingRequestHandler for information on how to use Solr Cell and what parameters are available.
-
-
- extractFromString -
-
- -
Use Solr Cell to extract document contents. See http://wiki.apache.org/solr/ExtractingRequestHandler for information on how to use Solr Cell and what parameters are available.
-
-
- extractFromString -
-
- -
Use Solr Cell to extract document contents. See http://wiki.apache.org/solr/ExtractingRequestHandler for information on how to use Solr Cell and what parameters are available.
-
-
- extractFromUrl -
-
- -
Use Solr Cell to extract document contents. See http://wiki.apache.org/solr/ExtractingRequestHandler for information on how to use Solr Cell and what parameters are available.
-
-
- EXTRACT_SERVLET -
-
- -
-
- -
-
f
- -
-
-
-
- FileGetContents.php -
-
-
FileGetContents.php in FileGetContents.php
-
-
- -
-
g
- -
-
-
-
- getBody -
-
- -
Get the raw response body
-
-
- getBoost -
-
- -
Get current document boost
-
-
- getCollapseSingleValueArrays -
-
- -
Get the current state of the collapse single value arrays flag.
-
-
- getCreateDocuments -
-
- -
Get the current state of teh create documents flag.
-
-
- getCreateDocuments -
-
- -
Get the current state of teh create documents flag.
-
-
- getDefaultStatusMessage -
-
- -
Get the HTTP status message based on status code
-
-
- getDefaultTimeout -
-
- -
Get the current default timeout setting (initially the default_socket_timeout ini setting) in seconds
-
-
- getDefaultTimeout -
-
- -
Get the current default timeout for all HTTP requests
-
-
- getDefaultTimeout -
-
- -
Get the current default timeout setting (initially the default_socket_timeout ini setting) in seconds
-
-
- getEncoding -
-
- -
Get the charset encoding of the response body.
-
-
- getEncoding -
-
- -
Get character encoding of this response. Should usually be utf-8, but just in case
-
-
- getField -
-
- -
Get field information
-
-
- getFieldBoost -
-
- -
Get the currently set field boost for a document field
-
-
- getFieldBoosts -
-
- -
Return current field boosts, indexed by field name
-
-
- getFieldNames -
-
- -
Get the names of all fields in this document
-
-
- getFieldValues -
-
- -
Get the values 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
-
-
- getHttpTransport -
-
- -
Get the current configured HTTP Transport
-
-
- getIterator -
-
- -
IteratorAggregate implementation function. Allows usage:
-
-
- getMimeType -
-
- -
Get the mimetype of the response body
-
-
- 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
-
-
- getResponse -
-
- -
Get the response for which this exception was generated
-
-
- getStatusCode -
-
- -
Get the status code of the response
-
-
- getStatusMessage -
-
- -
Get the status message of the response
-
-
- getType -
-
- -
Get content type of this Solr response
-
-
- -
-
h
- -
-
-
-
- HttpTransportException.php -
-
-
HttpTransportException.php in HttpTransportException.php
-
-
- -
-
i
- -
-
-
-
- Interface.php -
-
-
Interface.php in Interface.php
-
-
- InvalidArgumentException.php -
-
-
InvalidArgumentException.php in InvalidArgumentException.php
-
-
- -
-
m
- -
-
-
-
- METHOD_GET -
-
- -
Search HTTP Methods
-
-
- METHOD_POST -
-
- -
-
- -
-
n
- -
-
-
-
- NAMED_LIST_FLAT -
-
- -
NamedList Treatment constants
-
-
- NAMED_LIST_MAP -
-
- -
-
- NoServiceAvailableException.php -
-
-
NoServiceAvailableException.php in NoServiceAvailableException.php
-
-
- -
-
o
- -
-
-
-
- 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
- -
-
-
-
- ParserException.php -
-
-
ParserException.php in ParserException.php
-
-
- performGetRequest -
-
- -
-
- performGetRequest -
-
- -
-
- performGetRequest -
-
- -
-
- performGetRequest -
-
- -
Perform a GET HTTP operation with an optional timeout and return the response contents, use getLastResponseHeaders to retrieve HTTP headers
-
-
- performHeadRequest -
-
- -
Perform a HEAD HTTP operation with an optional timeout and return the response headers - NOTE: head requests have no response body
-
-
- performHeadRequest -
-
- -
-
- performHeadRequest -
-
- -
-
- performHeadRequest -
-
- -
-
- performPostRequest -
-
- -
-
- performPostRequest -
-
- -
Perform a POST HTTP operation with an optional timeout and return the response contents, use getLastResponseHeaders to retrieve HTTP headers
-
-
- performPostRequest -
-
- -
-
- performPostRequest -
-
- -
-
- 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
- -
-
-
-
- Response.php -
-
-
Response.php in Response.php
-
-
- 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
-
-
- -
-
s
- -
-
-
-
- search -
-
- -
Simple Search interface
-
-
- search -
-
- -
Simple Search interface
-
-
- SEARCH_SERVLET -
-
- -
-
- Service.php -
-
-
Service.php in Service.php
-
-
- setBoost -
-
- -
Set document boost factor
-
-
- 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 -
-
- -
Set the create documents flag. This determines whether Apache_Solr_Response objects will parse the response and create Apache_Solr_Document instances in place.
-
-
- setDefaultTimeout -
-
- -
Set the current default timeout for all HTTP requests
-
-
- setDefaultTimeout -
-
- -
Set the default timeout for all calls that aren't passed a specific timeout
-
-
- setDefaultTimeout -
-
- -
Set the current default timeout for all HTTP requests
-
-
- setField -
-
- -
Set a field value. Multi-valued fields should be set as arrays or instead use the addField(...) function which will automatically make sure the field is an array.
-
-
- setFieldBoost -
-
- -
Set the field boost for a document field
-
-
- setHost -
-
- -
Set the host used. If empty will fallback to constants
-
-
- setHttpTransport -
-
- -
Set the HTTP Transport implemenation that will be used for all HTTP requests
-
-
- setMultiValue -
-
- -
Handle the array manipulation for a multi-valued field
-
-
- setNamedListTreatment -
-
- -
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_WRITER -
-
- -
Response writer we'll request - JSON. See http://code.google.com/p/solr-php-client/issues/detail?id=6#c1 for reasoning
-
-
- SVN_ID -
-
- -
SVN ID meta data for this class
-
-
- SVN_ID -
-
- -
SVN ID meta data for this class
-
-
- SVN_ID -
-
- -
SVN ID meta data for this class
-
-
- SVN_ID -
-
- -
SVN ID meta data for this class
-
-
- SVN_ID -
-
- -
SVN ID meta data for this class
-
-
- SVN_ID -
-
-
Apache_Solr_InvalidArgumentException::SVN_ID in InvalidArgumentException.php
-
SVN ID meta data for this class
-
-
- SVN_ID -
-
- -
SVN ID meta data for this class
-
-
- SVN_ID -
-
-
Apache_Solr_HttpTransportException::SVN_ID in HttpTransportException.php
-
SVN ID meta data for this class
-
-
- SVN_ID -
-
- -
SVN ID meta data for this class
-
-
- SVN_ID -
-
-
Apache_Solr_NoServiceAvailableException::SVN_ID in NoServiceAvailableException.php
-
SVN ID meta data for this class
-
-
- SVN_ID -
-
- -
SVN ID meta data for this class
-
-
- SVN_ID -
-
- -
SVN ID meta data for this class
-
-
- SVN_REVISION -
-
- -
SVN Revision meta data for this class
-
-
- SVN_REVISION -
-
- -
SVN Revision meta data for this class
-
-
- SVN_REVISION -
-
- -
SVN Revision meta data for this class
-
-
- SVN_REVISION -
-
- -
SVN Revision meta data for this class
-
-
- SVN_REVISION -
-
- -
SVN Revision meta data for this class
-
-
- SVN_REVISION -
-
- -
SVN Revision meta data for this class
-
-
- SVN_REVISION -
-
- -
SVN Revision meta data for this class
-
-
- SVN_REVISION -
-
- -
SVN Revision meta data for this class
-
-
- SVN_REVISION -
-
- -
SVN Revision meta data for this class
-
-
- SVN_REVISION -
-
- -
SVN Revision meta data for this class
-
-
- SVN_REVISION -
-
- -
SVN Revision meta data for this class
-
-
- SVN_REVISION -
-
- -
SVN Revision meta data for this class
-
-
- -
-
t
- -
-
-
-
- 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
- -
-
-
-
- UPDATE_SERVLET -
-
- -
-
- -
- a - b - c - d - e - f - g - h - i - m - n - o - p - r - s - t - u - _ -
- \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/errors.html b/SolrPhpClient/phpdocs/errors.html deleted file mode 100644 index 56c8e288..00000000 --- a/SolrPhpClient/phpdocs/errors.html +++ /dev/null @@ -1,95 +0,0 @@ - - - - - - phpDocumentor Parser Errors and Warnings - - - - - Post-parsing
-Balancer.php
-Curl.php
-CurlNoReuse.php
-Document.php
-Exception.php
-FileGetContents.php
-HttpTransportException.php
-Interface.php
-InvalidArgumentException.php
-NoServiceAvailableException.php
-ParserException.php
-Response.php
-Service.php
- -

Abstract.php

-

Warnings:


-Warning on line 43 - no @package tag was used in a DocBlock for class Apache_Solr_HttpTransport_Abstract
- -

Balancer.php

-

Warnings:


-Warning on line 40 - Page-level DocBlock precedes "require_once dirname(dirname(__FILE__)).'/Service.php'", use another DocBlock to document the source element
-Warning on line 51 - no @package tag was used in a DocBlock for class Apache_Solr_Service_Balancer
- -

Curl.php

-

Warnings:


-Warning on line 39 - Page-level DocBlock precedes "require_once dirname(__FILE__).'/Abstract.php'", use another DocBlock to document the source element
-Warning on line 45 - no @package tag was used in a DocBlock for class Apache_Solr_HttpTransport_Curl
- -

CurlNoReuse.php

-

Warnings:


-Warning on line 39 - Page-level DocBlock precedes "require_once dirname(__FILE__).'/Abstract.php'", use another DocBlock to document the source element
-Warning on line 47 - no @package tag was used in a DocBlock for class Apache_Solr_HttpTransport_CurlNoReuse
- -

Document.php

-

Warnings:


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

Errors:


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

Exception.php

-

Warnings:


-Warning on line 39 - DocBlock would be page-level, but precedes class "Apache_Solr_Exception", use another DocBlock to document the file
- -

FileGetContents.php

-

Warnings:


-Warning on line 39 - Page-level DocBlock precedes "require_once dirname(__FILE__).'/Abstract.php'", use another DocBlock to document the source element
-Warning on line 45 - no @package tag was used in a DocBlock for class Apache_Solr_HttpTransport_FileGetContents
- -

HttpTransportException.php

-

Warnings:


-Warning on line 39 - DocBlock would be page-level, but precedes class "Apache_Solr_HttpTransportException", use another DocBlock to document the file
- -

Interface.php

-

Warnings:


-Warning on line 39 - Page-level DocBlock precedes "require_once dirname(__FILE__).'/Response.php'", use another DocBlock to document the source element
-Warning on line 47 - no @package tag was used in a DocBlock for interface Apache_Solr_HttpTransport_Interface
- -

InvalidArgumentException.php

-

Warnings:


-Warning on line 39 - DocBlock would be page-level, but precedes class "Apache_Solr_InvalidArgumentException", use another DocBlock to document the file
- -

NoServiceAvailableException.php

-

Warnings:


-Warning on line 39 - DocBlock would be page-level, but precedes class "Apache_Solr_NoServiceAvailableException", use another DocBlock to document the file
- -

ParserException.php

-

Warnings:


-Warning on line 39 - DocBlock would be page-level, but precedes class "Apache_Solr_ParserException", use another DocBlock to document the file
- -

Response.php

-

Warnings:


-Warning on line 38 - Page-level DocBlock precedes "require_once dirname(__FILE__).'/ParserException.php'", use another DocBlock to document the source element
-Warning on line 44 - no @package tag was used in a DocBlock for class Apache_Solr_HttpTransport_Response
-Warning on line 48 - no @package tag was used in a DocBlock for class Apache_Solr_Response
- -

Service.php

-

Warnings:


-Warning on line 40 - Page-level DocBlock precedes "require_once dirname(__FILE__).'/Exception.php'", use another DocBlock to document the source element
-Warning on line 86 - no @package tag was used in a DocBlock for class Apache_Solr_Service
-

- Documentation generated on Wed, 04 May 2011 11:01:19 -0400 by phpDocumentor 1.4.3 -

- - \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/index.html b/SolrPhpClient/phpdocs/index.html deleted file mode 100644 index dd90e526..00000000 --- a/SolrPhpClient/phpdocs/index.html +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - 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> - - - \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/li_Apache.html b/SolrPhpClient/phpdocs/li_Apache.html deleted file mode 100644 index 9b6e2b6e..00000000 --- a/SolrPhpClient/phpdocs/li_Apache.html +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - -
Apache
- -

phpDocumentor v 1.4.3

- - \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/media/banner.css b/SolrPhpClient/phpdocs/media/banner.css deleted file mode 100644 index ba1a7ba5..00000000 --- a/SolrPhpClient/phpdocs/media/banner.css +++ /dev/null @@ -1,32 +0,0 @@ -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; -} diff --git a/SolrPhpClient/phpdocs/media/stylesheet.css b/SolrPhpClient/phpdocs/media/stylesheet.css deleted file mode 100644 index 051586b3..00000000 --- a/SolrPhpClient/phpdocs/media/stylesheet.css +++ /dev/null @@ -1,142 +0,0 @@ -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 } - diff --git a/SolrPhpClient/phpdocs/packages.html b/SolrPhpClient/phpdocs/packages.html deleted file mode 100644 index 97fe3802..00000000 --- a/SolrPhpClient/phpdocs/packages.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/SolrPhpClient/phpdocs/todolist.html b/SolrPhpClient/phpdocs/todolist.html deleted file mode 100644 index 1490bd8d..00000000 --- a/SolrPhpClient/phpdocs/todolist.html +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - Todo List - - - - -

Todo List

-

Apache

-

Apache_Solr_Service

-
    -
  • 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
  • -
-

Apache_Solr_Service::extractFromString()

-
    -
  • Should be using multipart/form-data to post parameter values, but I could not get my implementation to work. Needs revisisted.
  • -
-

Apache_Solr_Service_Balancer::extractFromString()

-
    -
  • Should be using multipart/form-data to post parameter values, but I could not get my implementation to work. Needs revisisted.
  • -
-

- Documentation generated on Wed, 04 May 2011 11:01:19 -0400 by phpDocumentor 1.4.3 -

- - \ No newline at end of file diff --git a/SolrPhpClient/tests/Apache/Solr/DocumentTest.php b/SolrPhpClient/tests/Apache/Solr/DocumentTest.php deleted file mode 100644 index 92261c8e..00000000 --- a/SolrPhpClient/tests/Apache/Solr/DocumentTest.php +++ /dev/null @@ -1,439 +0,0 @@ - - */ - -/** - * Apache_Solr_Document Unit Test - */ -class Apache_Solr_DocumentTest extends PHPUnit_Framework_TestCase -{ - /** - * Fixture used for testing - * - * @var Apache_Solr_Document - */ - private $_fixture; - - /** - * Setup for the fixture before each unit test - part of test case API - */ - protected function setup() - { - $this->_fixture = new Apache_Solr_Document(); - } - - /** - * Teardown after each unit test - part of test case API - */ - protected function tearDown() - { - unset($this->_fixture); - } - - public function testDefaultStateAfterConstructor() - { - // document boost should be false - $this->assertFalse($this->_fixture->getBoost()); - - // document fields should be empty - $this->assertEquals(0, count($this->_fixture->getFieldNames())); - $this->assertEquals(0, count($this->_fixture->getFieldValues())); - $this->assertEquals(0, count($this->_fixture->getFieldBoosts())); - - // document iterator should be empty - $this->assertEquals(0, iterator_count($this->_fixture)); - } - - public function testSetAndGetField() - { - $field = 'field'; - $value = 'value'; - $boost = 0.5; - - // set the field - $this->_fixture->setField($field, $value, $boost); - - $result = $this->_fixture->getField($field); - - // check the array values - $this->assertTrue(is_array($result)); - $this->assertEquals($field, $result['name']); - $this->assertEquals($value, $result['value']); - $this->assertEquals($boost, $result['boost']); - } - - public function testGetFieldReturnsFalseForNonExistentField() - { - $this->assertFalse($this->_fixture->getField('field')); - } - - public function testMagicGetForFieldValues() - { - $field = 'field'; - $value = 'value'; - - $this->_fixture->setField($field, $value); - - // test the __get value - $this->assertEquals($value, $this->_fixture->{$field}); - } - - /** - * Added for issue #48 (http://code.google.com/p/solr-php-client/issues/detail?id=48) - */ - public function testMagicGetReturnsNullForNonExistentField() - { - $this->assertNull($this->_fixture->nonExistent); - } - - public function testMagicSetForFieldValues() - { - $field = 'field'; - $value = 'value'; - - // set field value with magic __set - $this->_fixture->{$field} = $value; - - $fieldArray = $this->_fixture->getField($field); - - // set values - $this->assertEquals($field, $fieldArray['name']); - $this->assertEquals($value, $fieldArray['value']); - $this->assertTrue($fieldArray['boost'] === false); - } - - public function testMagicIssetForNonExistentField() - { - $this->assertFalse(isset($this->_fixture->field)); - } - - public function testMagicIssetForExistingField() - { - $field = 'field'; - $this->_fixture->{$field} = 'value'; - $this->assertTrue(isset($this->_fixture->{$field})); - } - - public function testMagicUnsetForExistingField() - { - $field = 'field'; - - $this->_fixture->{$field} = 'value'; - - // now unset the field - unset($this->_fixture->{$field}); - - // now test that its unset - $this->assertFalse(isset($this->_fixture->{$field})); - } - - public function testMagicUnsetForNonExistingField() - { - $field = 'field'; - unset($this->_fixture->{$field}); - - // now test that it still does not exist - $this->assertFalse(isset($this->_fixture->{$field})); - } - - public function testSetAndGetFieldBoostWithPositiveNumberSetsBoost() - { - $field = 'field'; - $boost = 0.5; - - $this->_fixture->setFieldBoost($field, $boost); - - // test the field boost - $this->assertEquals($boost, $this->_fixture->getFieldBoost($field)); - } - - public function testSetAndGetFieldBoostWithZeroRemovesBoost() - { - $field = 'field'; - $boost = 0; - - $this->_fixture->setFieldBoost($field, $boost); - - // test the field boost - $this->assertTrue($this->_fixture->getFieldBoost($field) === false); - } - - public function testSetAndGetFieldBoostWithNegativeNumberRemovesBoost() - { - $field = 'field'; - $boost = -1; - - $this->_fixture->setFieldBoost($field, $boost); - - // test the field boost - $this->assertTrue($this->_fixture->getFieldBoost($field) === false); - } - - public function testSetAndGetFieldBoostWithNonNumberRemovesBoost() - { - $field = 'field'; - $boost = "i am not a number"; - - $this->_fixture->setFieldBoost($field, $boost); - - // test the field boost - $this->assertTrue($this->_fixture->getFieldBoost($field) === false); - } - - public function testSetAndGetBoostWithPositiveNumberSetsBoost() - { - $boost = 0.5; - $this->_fixture->setBoost($boost); - - // the boost should now be set - $this->assertEquals($boost, $this->_fixture->getBoost()); - } - - public function testSetAndGetBoostWithZeroRemovesBoost() - { - $this->_fixture->setBoost(0); - - // should be boolean false - $this->assertTrue($this->_fixture->getBoost() === false); - } - - public function testSetAndGetBoostWithNegativeNumberRemovesBoost() - { - $this->_fixture->setBoost(-1); - - // should be boolean false - $this->assertTrue($this->_fixture->getBoost() === false); - } - - public function testSetAndGetBoostWithNonNumberRemovesBoost() - { - $this->_fixture->setBoost("i am not a number"); - - // should be boolean false - $this->assertTrue($this->_fixture->getBoost() === false); - } - - public function testAddFieldCreatesMultiValueWhenFieldDoesNotExist() - { - $field = 'field'; - $value = 'value'; - - $this->_fixture->addField($field, $value); - - // check that value is an array with correct values - $fieldValue = $this->_fixture->{$field}; - - $this->assertTrue(is_array($fieldValue)); - $this->assertEquals(1, count($fieldValue)); - $this->assertEquals($value, $fieldValue[0]); - } - - /** - * setMultiValue has been deprecated and defers to addField - * - * @deprecated - */ - public function testSetMultiValueCreateMultiValueWhenFieldDoesNotExist() - { - $field = 'field'; - $value = 'value'; - - $this->_fixture->setMultiValue($field, $value); - - // check that value is an array with correct values - $fieldValue = $this->_fixture->{$field}; - - $this->assertTrue(is_array($fieldValue)); - $this->assertEquals(1, count($fieldValue)); - $this->assertEquals($value, $fieldValue[0]); - } - - public function testAddFieldCreatesMultiValueWhenFieldDoesExistAsSingleValue() - { - $field = 'field'; - $value1 = 'value1'; - $value2 = 'value2'; - - // set first value as singular value - $this->_fixture->{$field} = $value1; - - // add a second value with addField - $this->_fixture->addField($field, $value2); - - // check that value is an array with correct values - $fieldValue = $this->_fixture->{$field}; - - $this->assertTrue(is_array($fieldValue)); - $this->assertEquals(2, count($fieldValue)); - $this->assertEquals($value1, $fieldValue[0]); - $this->assertEquals($value2, $fieldValue[1]); - } - - /** - * setMultiValue has been deprecated and defers to addField - * - * @deprecated - */ - public function testSetMultiValueCreatesMultiValueWhenFieldDoesExistAsSingleValue() - { - $field = 'field'; - $value1 = 'value1'; - $value2 = 'value2'; - - // set first value as singular value - $this->_fixture->{$field} = $value1; - - // add a second value with addField - $this->_fixture->setMultiValue($field, $value2); - - // check that value is an array with correct values - $fieldValue = $this->_fixture->{$field}; - - $this->assertTrue(is_array($fieldValue)); - $this->assertEquals(2, count($fieldValue)); - $this->assertEquals($value1, $fieldValue[0]); - $this->assertEquals($value2, $fieldValue[1]); - } - - public function testAddFieldWithBoostSetsFieldBoost() - { - $field = 'field'; - $boost = 0.5; - - $this->_fixture->addField($field, 'value', $boost); - - // check the field boost - $this->assertEquals($boost, $this->_fixture->getFieldBoost($field)); - } - - public function testAddFieldWithBoostMultipliesWithAPreexistingBoost() - { - $field = 'field'; - $boost = 0.5; - - // set a field with a boost - $this->_fixture->setField($field, 'value1', $boost); - - // now add another value with the same boost - $this->_fixture->addField($field, 'value2', $boost); - - // new boost should be $boost * $boost - $this->assertEquals($boost * $boost, $this->_fixture->getFieldBoost($field)); - } - - public function testGetFieldNamesIsInitiallyEmpty() - { - $fieldNames = $this->_fixture->getFieldNames(); - - $this->assertTrue(empty($fieldNames)); - } - - public function testGetFieldNamesAfterFieldIsSetIsNotEmpty() - { - $field = 'field'; - - $this->_fixture->{$field} = 'value'; - $fieldNames = $this->_fixture->getFieldNames(); - - $this->assertTrue(!empty($fieldNames)); - $this->assertEquals(1, count($fieldNames)); - $this->assertEquals($field, $fieldNames[0]); - } - - public function testGetFieldValuesIsInitiallyEmpty() - { - $fieldValues = $this->_fixture->getFieldValues(); - - $this->assertTrue(empty($fieldValues)); - } - - public function testGetFieldValuessAfterFieldIsSetIsNotEmpty() - { - $value = 'value'; - - $this->_fixture->field = $value; - $fieldValues = $this->_fixture->getFieldValues(); - - $this->assertTrue(!empty($fieldValues)); - $this->assertEquals(1, count($fieldValues)); - $this->assertEquals($value, $fieldValues[0]); - } - - public function testGetIteratorAfterFieldValueIsSet() - { - $field = 'field'; - $value = 'value'; - - $this->_fixture->{$field} = $value; - - $itemCount = 0; - - foreach ($this->_fixture as $iteratedField => $iteratedValue) - { - ++$itemCount; - - // test field and value - $this->assertEquals($field, $iteratedField); - $this->assertEquals($value, $iteratedValue); - } - - // test number of iterations is 1 - $this->assertEquals(1, $itemCount); - } - - public function testClearReturnsDocumentToDefaultState() - { - // set the document boost - $this->_fixture->setBoost(0.5); - - // set a field - $this->_fixture->someField = "some value"; - - // clear the document to remove boost and fields - $this->_fixture->clear(); - - // document boost should now be false - $this->assertFalse($this->_fixture->getBoost()); - - // document fields should now be empty - $this->assertEquals(0, count($this->_fixture->getFieldNames())); - $this->assertEquals(0, count($this->_fixture->getFieldValues())); - $this->assertEquals(0, count($this->_fixture->getFieldBoosts())); - - // document iterator should now be empty - $this->assertEquals(0, iterator_count($this->_fixture)); - } -} \ No newline at end of file diff --git a/SolrPhpClient/tests/Apache/Solr/HttpTransport/AbstractTest.php b/SolrPhpClient/tests/Apache/Solr/HttpTransport/AbstractTest.php deleted file mode 100644 index a16e8b6d..00000000 --- a/SolrPhpClient/tests/Apache/Solr/HttpTransport/AbstractTest.php +++ /dev/null @@ -1,208 +0,0 @@ - - */ - -/** - * Apache_Solr_HttpTransport_Abstract Unit Tests - */ -abstract class Apache_Solr_HttpTransport_AbstractTest extends PHPUnit_Framework_TestCase -{ - const TIMEOUT = 2; - - // request our copyright file from googlecode for GET and HEAD - const GET_URL = "http://solr-php-client.googlecode.com/svn/trunk/COPYING"; - const GET_RESPONSE_MIME_TYPE = 'text/plain'; - const GET_RESPONSE_ENCODING = 'UTF-8'; - const GET_RESPONSE_MATCH = 'Copyright (c) '; - - // post to the issue list page with a search for 'meh' - const POST_URL = "http://code.google.com/p/solr-php-client/issues/list"; - const POST_DATA = "can=2&q=meh&colspec=ID+Type+Status+Priority+Milestone+Owner+Summary&cells=tiles"; - const POST_REQUEST_CONTENT_TYPE = 'application/x-www-form-urlencoded; charset=UTF-8'; - - const POST_RESPONSE_MIME_TYPE = 'text/html'; - const POST_RESPONSE_ENCODING = 'UTF-8'; - //const POST_RESPONSE_MATCH = 'not sure'; - - abstract public function getFixture(); - - public function testGetDefaultTimeoutWithDefaultConstructor() - { - $fixture = $this->getFixture(); - $timeout = $fixture->getDefaultTimeout(); - - $this->assertGreaterThan(0, $timeout); - } - - public function testGetDefaultTimeoutSetToSixtyForBadValues() - { - // first set our default_socket_timeout ini setting - $previousValue = ini_get('default_socket_timeout'); - ini_set('default_socket_timeout', 0); - - $fixture = $this->getFixture(); - $timeout = $fixture->getDefaultTimeout(); - - // reset timeout - ini_set('default_socket_timeout', $previousValue); - - $this->assertEquals(60, $timeout); - } - - public function testSetDefaultTimeout() - { - $newTimeout = 1234; - - $fixture = $this->getFixture(); - $fixture->setDefaultTimeout($newTimeout); - $timeout = $fixture->getDefaultTimeout(); - - $this->assertEquals($newTimeout, $timeout); - } - - public function testPerformGetRequest() - { - $fixture = $this->getFixture(); - $fixture->setDefaultTimeout(self::TIMEOUT); - - $response = $fixture->performGetRequest(self::GET_URL); - - $this->assertType('Apache_Solr_HttpTransport_Response', $response); - - $this->assertEquals(200, $response->getStatusCode(), 'Status code was not 200'); - $this->assertEquals(self::GET_RESPONSE_MIME_TYPE, $response->getMimeType(), 'mimetype was not correct'); - $this->assertEquals(self::GET_RESPONSE_ENCODING, $response->getEncoding(), 'character encoding was not correct'); - $this->assertStringStartsWith(self::GET_RESPONSE_MATCH, $response->getBody(), 'body did not start with match text'); - } - - public function testPerformGetRequestWithTimeout() - { - $fixture = $this->getFixture(); - $response = $fixture->performGetRequest(self::GET_URL, self::TIMEOUT); - - $this->assertType('Apache_Solr_HttpTransport_Response', $response); - - $this->assertEquals(200, $response->getStatusCode(), 'Status code was not 200'); - $this->assertEquals(self::GET_RESPONSE_MIME_TYPE, $response->getMimeType(), 'mimetype was not correct'); - $this->assertEquals(self::GET_RESPONSE_ENCODING, $response->getEncoding(), 'character encoding was not correct'); - $this->assertStringStartsWith(self::GET_RESPONSE_MATCH, $response->getBody(), 'body did not start with match text'); - } - - public function testPerformHeadRequest() - { - $fixture = $this->getFixture(); - $fixture->setDefaultTimeout(self::TIMEOUT); - - $response = $fixture->performHeadRequest(self::GET_URL); - - // we should get everything the same as a get, except the body - $this->assertType('Apache_Solr_HttpTransport_Response', $response); - - $this->assertEquals(200, $response->getStatusCode(), 'Status code was not 200'); - $this->assertEquals(self::GET_RESPONSE_MIME_TYPE, $response->getMimeType(), 'mimetype was not correct'); - $this->assertEquals(self::GET_RESPONSE_ENCODING, $response->getEncoding(), 'character encoding was not correct'); - $this->assertEquals("", $response->getBody(), 'body was not empty'); - } - - public function testPerformHeadRequestWithTimeout() - { - $fixture = $this->getFixture(); - $response = $fixture->performHeadRequest(self::GET_URL, self::TIMEOUT); - - // we should get everything the same as a get, except the body - $this->assertType('Apache_Solr_HttpTransport_Response', $response); - - $this->assertEquals(200, $response->getStatusCode(), 'Status code was not 200'); - $this->assertEquals(self::GET_RESPONSE_MIME_TYPE, $response->getMimeType(), 'mimetype was not correct'); - $this->assertEquals(self::GET_RESPONSE_ENCODING, $response->getEncoding(), 'character encoding was not correct'); - $this->assertEquals("", $response->getBody(), 'body was not empty'); - } - - public function testPerformPostRequest() - { - $fixture = $this->getFixture(); - $fixture->setDefaultTimeout(self::TIMEOUT); - - $response = $fixture->performPostRequest(self::POST_URL, self::POST_DATA, self::POST_REQUEST_CONTENT_TYPE); - - $this->assertType('Apache_Solr_HttpTransport_Response', $response); - - $this->assertEquals(200, $response->getStatusCode(), 'Status code was not 200'); - $this->assertEquals(self::POST_RESPONSE_MIME_TYPE, $response->getMimeType(), 'mimetype was not correct'); - $this->assertEquals(self::POST_RESPONSE_ENCODING, $response->getEncoding(), 'character encoding was not correct'); - //$this->assertStringStartsWith(self::POST_RESPONSE_MATCH, $response->getBody(), 'body did not start with match text'); - } - - public function testPerformPostRequestWithTimeout() - { - $fixture = $this->getFixture(); - $response = $fixture->performPostRequest(self::POST_URL, self::POST_DATA, self::POST_REQUEST_CONTENT_TYPE, self::TIMEOUT); - - $this->assertType('Apache_Solr_HttpTransport_Response', $response); - - $this->assertEquals(200, $response->getStatusCode(), 'Status code was not 200'); - $this->assertEquals(self::POST_RESPONSE_MIME_TYPE, $response->getMimeType(), 'mimetype was not correct'); - $this->assertEquals(self::POST_RESPONSE_ENCODING, $response->getEncoding(), 'character encoding was not correct'); - //$this->assertStringStartsWith(self::POST_RESPONSE_MATCH, $response->getBody(), 'body did not start with match text'); - } - - /** - * Test one session doing multiple requests in multiple orders - */ - public function testMultipleRequests() - { - // initial get request - $this->testPerformGetRequest(); - - // head following get - $this->testPerformHeadRequest(); - - // post following head - $this->testPerformPostRequest(); - - // get following post - $this->testPerformGetRequest(); - - // post following get - $this->testPerformPostRequest(); - - // head following post - $this->testPerformHeadRequest(); - - // get following post - $this->testPerformGetRequest(); - } -} \ No newline at end of file diff --git a/SolrPhpClient/tests/Apache/Solr/HttpTransport/CurlNoReuseTest.php b/SolrPhpClient/tests/Apache/Solr/HttpTransport/CurlNoReuseTest.php deleted file mode 100644 index 0484dd4d..00000000 --- a/SolrPhpClient/tests/Apache/Solr/HttpTransport/CurlNoReuseTest.php +++ /dev/null @@ -1,53 +0,0 @@ - - */ - -/** - * Apache_Solr_HttpTransport_CurlNoReuse Unit Tests - */ -class Apache_Solr_HttpTransport_CurlNoReuseTest extends Apache_Solr_HttpTransport_AbstractTest -{ - public function getFixture() - { - // ensure curl is enabled - if (!extension_loaded('curl')) - { - $this->markTestSkipped("curl module is not enabled"); - } - - return new Apache_Solr_HttpTransport_CurlNoReuse(); - } -} diff --git a/SolrPhpClient/tests/Apache/Solr/HttpTransport/CurlTest.php b/SolrPhpClient/tests/Apache/Solr/HttpTransport/CurlTest.php deleted file mode 100644 index 070c164f..00000000 --- a/SolrPhpClient/tests/Apache/Solr/HttpTransport/CurlTest.php +++ /dev/null @@ -1,53 +0,0 @@ - - */ - -/** - * Apache_Solr_HttpTransport_Curl Unit Tests - */ -class Apache_Solr_HttpTransport_CurlTest extends Apache_Solr_HttpTransport_AbstractTest -{ - public function getFixture() - { - // ensure curl is enabled - if (!extension_loaded('curl')) - { - $this->markTestSkipped("curl module is not enabled"); - } - - return new Apache_Solr_HttpTransport_Curl(); - } -} diff --git a/SolrPhpClient/tests/Apache/Solr/HttpTransport/FileGetContentsTest.php b/SolrPhpClient/tests/Apache/Solr/HttpTransport/FileGetContentsTest.php deleted file mode 100644 index 2e4f8e90..00000000 --- a/SolrPhpClient/tests/Apache/Solr/HttpTransport/FileGetContentsTest.php +++ /dev/null @@ -1,53 +0,0 @@ - - */ - -/** - * Apache_Solr_HttpTransport_FileGetContents Unit Tests - */ -class Apache_Solr_HttpTransport_FileGetContentsTest extends Apache_Solr_HttpTransport_AbstractTest -{ - public function getFixture() - { - // make sure allow_url_fopen is on - if (!ini_get("allow_url_fopen")) - { - $this->markTestSkipped("allow_url_fopen is not enabled"); - } - - return new Apache_Solr_HttpTransport_FileGetContents(); - } -} \ No newline at end of file diff --git a/SolrPhpClient/tests/Apache/Solr/HttpTransport/ResponseTest.php b/SolrPhpClient/tests/Apache/Solr/HttpTransport/ResponseTest.php deleted file mode 100644 index f3c11273..00000000 --- a/SolrPhpClient/tests/Apache/Solr/HttpTransport/ResponseTest.php +++ /dev/null @@ -1,164 +0,0 @@ - - */ - -/** - * Apache_Solr_HttpTransport_Response Unit Tests - */ -class Apache_Solr_HttpTransport_ResponseTest extends PHPUnit_Framework_TestCase -{ - // generated with the following query string: select?q=solr&wt=json - const STATUS_CODE_200 = 200; - const STATUS_MESSAGE_200 = "OK"; - const BODY_200 = '{"responseHeader":{"status":0,"QTime":0,"params":{"q":"solr","wt":"json"}},"response":{"numFound":0,"start":0,"docs":[]}}'; - const BODY_200_WITH_DOCUMENTS = '{"responseHeader":{"status":0,"QTime":0,"params":{"q":"*:*","wt":"json"}},"response":{"numFound":1,"start":0,"docs":[{"guid":"dev/2/products/45410/1236981","cit_domain":"products","cit_client":"2","cit_instance":"dev","cit_timestamp":"2010-10-06T18:16:51.573Z","product_code_t":["235784"],"product_id":[1236981],"dealer_id":[45410],"category_id":[1030],"manufacturer_id":[0],"vendor_id":[472],"catalog_id":[202]}]}}'; - const CONTENT_TYPE_200 = "text/plain; charset=utf-8"; - const MIME_TYPE_200 = "text/plain"; - const ENCODING_200 = "utf-8"; - - // generated with the following query string: select?qt=standad&q=solr&wt=json - // NOTE: the intentional mispelling of the standard in the qt parameter - const STATUS_CODE_400 = 400; - const STATUS_MESSAGE_400 = "Bad Request"; - const BODY_400 = 'Apache Tomcat/6.0.24 - Error report

HTTP Status 400 - unknown handler: standad


type Status report

message unknown handler: standad

description The request sent by the client was syntactically incorrect (unknown handler: standad).


Apache Tomcat/6.0.24

'; - const CONTENT_TYPE_400 = "text/html; charset=utf-8"; - const MIME_TYPE_400 = "text/html"; - const ENCODING_400 = "utf-8"; - - // generated with the following query string: select?q=solr&wt=json on a core that does not exist - const STATUS_CODE_404 = 404; - const STATUS_MESSAGE_404 = "Not Found"; - const BODY_404 = 'Apache Tomcat/6.0.24 - Error report

HTTP Status 404 - /solr/doesnotexist/select


type Status report

message /solr/doesnotexist/select

description The requested resource (/solr/doesnotexist/select) is not available.


Apache Tomcat/6.0.24

'; - const CONTENT_TYPE_404 = "text/html; charset=utf-8"; - const MIME_TYPE_404 = "text/html"; - const ENCODING_404 = "utf-8"; - - public static function get0Response() - { - return new Apache_Solr_HttpTransport_Response(null, null, null); - } - - public static function get200Response() - { - return new Apache_Solr_HttpTransport_Response(self::STATUS_CODE_200, self::CONTENT_TYPE_200, self::BODY_200); - } - - public static function get200ResponseWithDocuments() - { - return new Apache_Solr_HttpTransport_Response(self::STATUS_CODE_200, self::CONTENT_TYPE_200, self::BODY_200_WITH_DOCUMENTS); - } - - public static function get400Response() - { - return new Apache_Solr_HttpTransport_Response(self::STATUS_CODE_400, self::CONTENT_TYPE_400, self::BODY_400); - } - - public static function get404Response() - { - return new Apache_Solr_HttpTransport_Response(self::STATUS_CODE_404, self::CONTENT_TYPE_404, self::BODY_404); - } - - public function testGetStatusCode() - { - $fixture = self::get200Response(); - - $statusCode = $fixture->getStatusCode(); - - $this->assertEquals(self::STATUS_CODE_200, $statusCode); - } - - public function testGetStatusMessage() - { - $fixture = self::get200Response(); - - $statusMessage = $fixture->getStatusMessage(); - - $this->assertEquals(self::STATUS_MESSAGE_200, $statusMessage); - } - - public function testGetStatusMessageWithUnknownCode() - { - $fixture = new Apache_Solr_HttpTransport_Response(499, null, null); - - $statusMessage = $fixture->getStatusMessage(); - $this->assertEquals("Unknown Status", $statusMessage); - } - - public function testGetBody() - { - $fixture = self::get200Response(); - - $body = $fixture->getBody(); - - $this->assertEquals(self::BODY_200, $body); - } - - public function testGetMimeType() - { - $fixture = self::get200Response(); - - $mimeType = $fixture->getMimeType(); - - $this->assertEquals(self::MIME_TYPE_200, $mimeType); - } - - public function testGetEncoding() - { - $fixture = self::get200Response(); - - $encoding = $fixture->getEncoding(); - - $this->assertEquals(self::ENCODING_200, $encoding); - } - - public function testGetStatusMessageWhenNotProvided() - { - // test 4 of the most common status code responses, probably don't need - // to test all the codes we have - - $fixture = new Apache_Solr_HttpTransport_Response(null, null, null, null, null); - $this->assertEquals("Communication Error", $fixture->getStatusMessage(), 'Did not get correct default status message for status code 0'); - - $fixture = new Apache_Solr_HttpTransport_Response(200, null, null, null, null); - $this->assertEquals("OK", $fixture->getStatusMessage(), 'Did not get correct default status message for status code 200'); - - $fixture = new Apache_Solr_HttpTransport_Response(400, null, null, null, null); - $this->assertEquals("Bad Request", $fixture->getStatusMessage(), 'Did not get correct default status message for status code 400'); - - $fixture = new Apache_Solr_HttpTransport_Response(404, null, null, null, null); - $this->assertEquals("Not Found", $fixture->getStatusMessage(), 'Did not get correct default status message for status code 404'); - } -} diff --git a/SolrPhpClient/tests/Apache/Solr/HttpTransportExceptionTest.php b/SolrPhpClient/tests/Apache/Solr/HttpTransportExceptionTest.php deleted file mode 100644 index a0958753..00000000 --- a/SolrPhpClient/tests/Apache/Solr/HttpTransportExceptionTest.php +++ /dev/null @@ -1,58 +0,0 @@ - - */ - -/** - * Apache_Solr_HttpTransportException Unit Tests - */ -class Apache_Solr_HttpTransportExceptionTest extends PHPUnit_Framework_TestCase -{ - /** - * @expectedException PHPUnit_Framework_Error - */ - public function testConstructorRequiresResponse() - { - $fixture = new Apache_Solr_HttpTransportException(); - } - - public function testGetResponse() - { - $response = Apache_Solr_ResponseTest::get0Response(); - $fixture = new Apache_Solr_HttpTransportException($response); - - $this->assertEquals($response, $fixture->getResponse()); - } -} diff --git a/SolrPhpClient/tests/Apache/Solr/ResponseTest.php b/SolrPhpClient/tests/Apache/Solr/ResponseTest.php deleted file mode 100644 index 6ba4fe99..00000000 --- a/SolrPhpClient/tests/Apache/Solr/ResponseTest.php +++ /dev/null @@ -1,194 +0,0 @@ - - */ - -/** - * Apache_Solr_Response Unit Test - */ -class Apache_Solr_ResponseTest extends PHPUnit_Framework_TestCase -{ - static public function get0Response($createDocuments = true, $collapseSingleValueArrays = true) - { - return new Apache_Solr_Response(Apache_Solr_HttpTransport_ResponseTest::get0Response(), $createDocuments, $collapseSingleValueArrays); - } - - static public function get200Response($createDocuments = true, $collapseSingleValueArrays = true) - { - return new Apache_Solr_Response(Apache_Solr_HttpTransport_ResponseTest::get200Response(), $createDocuments, $collapseSingleValueArrays); - } - - static public function get200ResponseWithDocuments($createDocuments = true, $collapseSingleValueArrays = true) - { - return new Apache_Solr_Response(Apache_Solr_HttpTransport_ResponseTest::get200ResponseWithDocuments(), $createDocuments, $collapseSingleValueArrays); - } - - static public function get400Response($createDocuments = true, $collapseSingleValueArrays = true) - { - return new Apache_Solr_Response(Apache_Solr_HttpTransport_ResponseTest::get400Response(), $createDocuments, $collapseSingleValueArrays); - } - - static public function get404Response($createDocuments = true, $collapseSingleValueArrays = true) - { - return new Apache_Solr_Response(Apache_Solr_HttpTransport_ResponseTest::get404Response(), $createDocuments, $collapseSingleValueArrays); - } - - public function testConstuctorWithValidBodyAndHeaders() - { - $fixture = self::get200Response(); - - // check that we parsed the HTTP status correctly - $this->assertEquals(Apache_Solr_HttpTransport_ResponseTest::STATUS_CODE_200, $fixture->getHttpStatus()); - - // check that we received the body correctly - $this->assertEquals(Apache_Solr_HttpTransport_ResponseTest::BODY_200, $fixture->getRawResponse()); - - // check that our defaults are correct - $this->assertEquals(Apache_Solr_HttpTransport_ResponseTest::ENCODING_200, $fixture->getEncoding()); - $this->assertEquals(Apache_Solr_HttpTransport_ResponseTest::MIME_TYPE_200, $fixture->getType()); - } - - public function testConstructorWithBadBodyAndHeaders() - { - $fixture = self::get0Response(); - - // check that our defaults are correct - $this->assertEquals(0, $fixture->getHttpStatus()); - $this->assertEquals("UTF-8", $fixture->getEncoding()); - $this->assertEquals("text/plain", $fixture->getType()); - } - - public function testMagicGetWithValidBodyAndHeaders() - { - $fixture = self::get200Response(); - - // test top level gets - $this->assertType('stdClass', $fixture->responseHeader); - $this->assertEquals(0, $fixture->responseHeader->status); - $this->assertEquals(0, $fixture->responseHeader->QTime); - - $this->assertType('stdClass', $fixture->response); - $this->assertEquals(0, $fixture->response->numFound); - - $this->assertTrue(is_array($fixture->response->docs)); - $this->assertEquals(0, count($fixture->response->docs)); - } - - /** - * @expectedException Apache_Solr_ParserException - */ - public function testMagicGetWith0Response() - { - $fixture = self::get0Response(); - - // attempting to magic get a part of the response - // should throw a ParserException - $fixture->responseHeader; - - $this->fail("Expected Apache_Solr_ParserException was not raised"); - } - - /** - * @expectedException Apache_Solr_ParserException - */ - public function testMagicGetWith400Response() - { - $fixture = self::get400Response(); - - // attempting to magic get a part of the response - // should throw a ParserException - $fixture->responseHeader; - - $this->fail("Expected Apache_Solr_ParserException was not raised"); - } - - /** - * @expectedException Apache_Solr_ParserException - */ - public function testMagicGetWith404Response() - { - $fixture = self::get404Response(); - - // attempting to magic get a part of the response - // should throw a ParserException - $fixture->responseHeader; - - $this->fail("Expected Apache_Solr_ParserException was not raised"); - } - - public function testCreateDocuments() - { - $fixture = self::get200ResponseWithDocuments(); - - $this->assertTrue(count($fixture->response->docs) > 0, 'There are not 1 or more documents, cannot test'); - $this->assertType('Apache_Solr_Document', $fixture->response->docs[0], 'The first document is not of type Apache_Solr_Document'); - } - - public function testDontCreateDocuments() - { - $fixture = self::get200ResponseWithDocuments(false); - - $this->assertTrue(count($fixture->response->docs) > 0, 'There are not 1 or more documents, cannot test'); - $this->assertType('stdClass', $fixture->response->docs[0], 'The first document is not of type stdClass'); - } - - public function testGetHttpStatusMessage() - { - $fixture = self::get200Response(); - - $this->assertEquals("OK", $fixture->getHttpStatusMessage()); - } - - public function testMagicGetReturnsNullForUndefinedData() - { - $fixture = self::get200Response(); - - $this->assertNull($fixture->doesnotexist); - } - - public function testMagicIssetForDefinedProperty() - { - $fixture = self::get200Response(); - - $this->assertTrue(isset($fixture->responseHeader)); - } - - public function testMagicIssetForUndefinedProperty() - { - $fixture = self::get200Response(); - - $this->assertFalse(isset($fixture->doesnotexist)); - } -} diff --git a/SolrPhpClient/tests/Apache/Solr/Service/BalancerTest.php b/SolrPhpClient/tests/Apache/Solr/Service/BalancerTest.php deleted file mode 100644 index df398749..00000000 --- a/SolrPhpClient/tests/Apache/Solr/Service/BalancerTest.php +++ /dev/null @@ -1,47 +0,0 @@ - - */ - -/** - * Apache_Solr_Service_Balancer Unit Tests - */ -class Apache_Solr_Service_BalancerTest extends Apache_Solr_ServiceAbstractTest -{ - public function getFixture() - { - return new Apache_Solr_Service_Balancer(); - } -} \ No newline at end of file diff --git a/SolrPhpClient/tests/Apache/Solr/ServiceAbstractTest.php b/SolrPhpClient/tests/Apache/Solr/ServiceAbstractTest.php deleted file mode 100644 index 0e8fdf52..00000000 --- a/SolrPhpClient/tests/Apache/Solr/ServiceAbstractTest.php +++ /dev/null @@ -1,139 +0,0 @@ - - */ - -/** - * Provides base funcationality test for both Apache_Solr_Service and the - * Apache_Solr_Service_Balancer classes. - */ -abstract class Apache_Solr_ServiceAbstractTest extends PHPUnit_Framework_TestCase -{ - /** - * Method that gets the appropriate instance for testing - */ - abstract public function getFixture(); - - /** - * @dataProvider testEscapeDataProvider - */ - public function testEscape($input, $expectedOutput) - { - $fixture = $this->getFixture(); - - $this->assertEquals($expectedOutput, $fixture->escape($input)); - } - - public function testEscapeDataProvider() - { - return array( - array( - "I should look the same", - "I should look the same" - ), - - array( - "(There) are: ^lots \\ && of spec!al charaters", - "\\(There\\) are\\: \\^lots \\\\ \\&& of spec\\!al charaters" - ) - ); - } - - /** - * @dataProvider testEscapePhraseDataProvider - */ - public function testEscapePhrase($input, $expectedOutput) - { - $fixture = $this->getFixture(); - - $this->assertEquals($expectedOutput, $fixture->escapePhrase($input)); - } - - public function testEscapePhraseDataProvider() - { - return array( - array( - "I'm a simple phrase", - "I'm a simple phrase" - ), - - array( - "I have \"phrase\" characters", - 'I have \\"phrase\\" characters' - ) - ); - } - - /** - * @dataProvider testPhraseDataProvider - */ - public function testPhrase($input, $expectedOutput) - { - $fixture = $this->getFixture(); - - $this->assertEquals($expectedOutput, $fixture->phrase($input)); - } - - public function testPhraseDataProvider() - { - return array( - array( - "I'm a simple phrase", - '"I\'m a simple phrase"' - ), - - array( - "I have \"phrase\" characters", - '"I have \\"phrase\\" characters"' - ) - ); - } - - public function testGetCreateDocumentWithDefaultConstructor() - { - $fixture = $this->getFixture(); - - $this->assertTrue($fixture->getCreateDocuments()); - } - - public function testSetCreateDocuments() - { - $fixture = $this->getFixture(); - - $fixture->setCreateDocuments(false); - - $this->assertFalse($fixture->getCreateDocuments()); - } -} \ No newline at end of file diff --git a/SolrPhpClient/tests/Apache/Solr/ServiceTest.php b/SolrPhpClient/tests/Apache/Solr/ServiceTest.php deleted file mode 100644 index 4f0284e0..00000000 --- a/SolrPhpClient/tests/Apache/Solr/ServiceTest.php +++ /dev/null @@ -1,1119 +0,0 @@ - - */ - -/** - * Apache_Solr_Service Unit Test - */ -class Apache_Solr_ServiceTest extends Apache_Solr_ServiceAbstractTest -{ - public function getFixture() - { - return new Apache_Solr_Service(); - } - - public function getMockHttpTransportInterface() - { - return $this->getMock( - 'Apache_Solr_HttpTransport_Interface', - array( - 'getDefaultTimeout', - 'setDefaultTimeout', - 'performGetRequest', - 'performHeadRequest', - 'performPostRequest', - ) - ); - } - - //================================================================// - // ATTEMPT TO MOVE THESE TO ServiceAbstractTest AT SOME POINT // - // Apache_Solr_Service_Balancer will need functions added // - //================================================================// - public function testGetHttpTransportWithDefaultConstructor() - { - $fixture = new Apache_Solr_Service(); - - $httpTransport = $fixture->getHttpTransport(); - - $this->assertInstanceOf('Apache_Solr_HttpTransport_Interface', $httpTransport, 'Default http transport does not implement interface'); - $this->assertInstanceOf('Apache_Solr_HttpTransport_FileGetContents', $httpTransport, 'Default http transport is not URL Wrapper implementation'); - } - - - public function testSetHttpTransport() - { - $newTransport = new Apache_Solr_HttpTransport_Curl(); - $fixture = new Apache_Solr_Service(); - - $fixture->setHttpTransport($newTransport); - $httpTransport = $fixture->getHttpTransport(); - - $this->assertInstanceOf('Apache_Solr_HttpTransport_Interface', $httpTransport); - $this->assertInstanceOf('Apache_Solr_HttpTransport_Curl', $httpTransport); - $this->assertEquals($newTransport, $httpTransport); - - } - - public function testSetHttpTransportWithConstructor() - { - $newTransport = new Apache_Solr_HttpTransport_Curl(); - - $fixture = new Apache_Solr_Service('localhost', 8180, '/solr/', $newTransport); - - $fixture->setHttpTransport($newTransport); - $httpTransport = $fixture->getHttpTransport(); - - $this->assertInstanceOf('Apache_Solr_HttpTransport_Interface', $httpTransport); - $this->assertInstanceOf('Apache_Solr_HttpTransport_Curl', $httpTransport); - $this->assertEquals($newTransport, $httpTransport); - } - - public function testGetCollapseSingleValueArraysWithDefaultConstructor() - { - $fixture = $this->getFixture(); - - $this->assertTrue($fixture->getCollapseSingleValueArrays()); - } - - public function testSetCollapseSingleValueArrays() - { - $fixture = $this->getFixture(); - - $fixture->setCollapseSingleValueArrays(false); - $this->assertFalse($fixture->getCollapseSingleValueArrays()); - } - - public function testGetNamedListTreatmetnWithDefaultConstructor() - { - $fixture = $this->getFixture(); - - $this->assertEquals(Apache_Solr_Service::NAMED_LIST_MAP, $fixture->getNamedListTreatment()); - } - - public function testSetNamedListTreatment() - { - $fixture = $this->getFixture(); - - $fixture->setNamedListTreatment(Apache_Solr_Service::NAMED_LIST_FLAT); - $this->assertEquals(Apache_Solr_Service::NAMED_LIST_FLAT, $fixture->getNamedListTreatment()); - - $fixture->setNamedListTreatment(Apache_Solr_Service::NAMED_LIST_MAP); - $this->assertEquals(Apache_Solr_Service::NAMED_LIST_MAP, $fixture->getNamedListTreatment()); - } - - /** - * @expectedException Apache_Solr_InvalidArgumentException - */ - public function testSetNamedListTreatmentInvalidArgumentException() - { - $fixture = $this->getFixture(); - - $fixture->setNamedListTreatment("broken"); - } - - //================================================================// - // END SECTION OF CODE THAT SHOULD BE MOVED // - // Apache_Solr_Service_Balancer will need functions added // - //================================================================// - - - public function testConstructorDefaultArguments() - { - $fixture = new Apache_Solr_Service(); - - $this->assertInstanceOf('Apache_Solr_Service', $fixture); - } - - public function testGetHostWithDefaultConstructor() - { - $fixture = new Apache_Solr_Service(); - $host = $fixture->getHost(); - - $this->assertEquals("localhost", $host); - } - - public function testSetHost() - { - $newHost = "example.com"; - - $fixture = new Apache_Solr_Service(); - $fixture->setHost($newHost); - $host = $fixture->getHost(); - - $this->assertEquals($newHost, $host); - } - - /** - * @expectedException Apache_Solr_InvalidArgumentException - */ - public function testSetEmptyHost() - { - $fixture = new Apache_Solr_Service(); - - // should throw an invalid argument exception - $fixture->setHost(""); - } - - public function testSetHostWithConstructor() - { - $newHost = "example.com"; - - $fixture = new Apache_Solr_Service($newHost); - $host = $fixture->getHost(); - - $this->assertEquals($newHost, $host); - } - - public function testGetPortWithDefaultConstructor() - { - $fixture = new Apache_Solr_Service(); - $port = $fixture->getPort(); - - $this->assertEquals(8180, $port); - } - - public function testSetPort() - { - $newPort = 12345; - - $fixture = new Apache_Solr_Service(); - $fixture->setPort($newPort); - $port = $fixture->getPort(); - - $this->assertEquals($newPort, $port); - } - - /** - * @expectedException Apache_Solr_InvalidArgumentException - */ - public function testSetPortWithInvalidArgument() - { - $fixture = new Apache_Solr_Service(); - - $fixture->setPort("broken"); - } - - public function testSetPortWithConstructor() - { - $newPort = 12345; - - $fixture = new Apache_Solr_Service('locahost', $newPort); - $port = $fixture->getPort(); - - $this->assertEquals($newPort, $port); - } - - public function testGetPathWithDefaultConstructor() - { - $fixture = new Apache_Solr_Service(); - $path = $fixture->getPath(); - - $this->assertEquals("/solr/", $path); - } - - public function testSetPath() - { - $newPath = "/new/path/"; - - $fixture = new Apache_Solr_Service(); - $fixture->setPath($newPath); - $path = $fixture->getPath(); - - $this->assertEquals($path, $newPath); - } - - public function testSetPathWillAddContainingSlashes() - { - $newPath = "new/path"; - $containedPath = "/{$newPath}/"; - - $fixture = new Apache_Solr_Service(); - $fixture->setPath($newPath); - $path = $fixture->getPath(); - - $this->assertEquals($containedPath, $path, 'setPath did not ensure propertly wrapped with slashes'); - } - - public function testSetPathWithConstructor() - { - $newPath = "/new/path/"; - - $fixture = new Apache_Solr_Service('localhost', 8180, $newPath); - $path = $fixture->getPath(); - - $this->assertEquals($newPath, $path); - } - - - public function testGetDefaultTimeoutCallsThroughToTransport() - { - $fixture = new Apache_Solr_Service(); - - // set a mock transport - $mockTransport = $this->getMockHttpTransportInterface(); - - // setup expected call - $mockTransport->expects($this->once())->method('getDefaultTimeout'); - - $fixture->setHttpTransport($mockTransport); - - $fixture->getDefaultTimeout(); - } - - public function testSetDefaultTimeoutCallsThroughToTransport() - { - $timeout = 12345; - $fixture = new Apache_Solr_Service(); - - // set a mock transport - $mockTransport = $this->getMockHttpTransportInterface(); - - // setup expected call - $mockTransport->expects($this->once())->method('setDefaultTimeout')->with($this->equalTo($timeout)); - - $fixture->setHttpTransport($mockTransport); - $fixture->setDefaultTimeout($timeout); - } - - public function testPing() - { - $expectedUrl = "http://localhost:8180/solr/admin/ping"; - $expectedTimeout = 2; - - // set a mock transport - $mockTransport = $this->getMockHttpTransportInterface(); - - // setup expected call and response - $mockTransport->expects($this->once()) - ->method('performHeadRequest') - ->with($this->equalTo($expectedUrl), $this->equalTo($expectedTimeout)) - ->will($this->returnValue(Apache_Solr_HttpTransport_ResponseTest::get200Response())); - - // call ping - $fixture = new Apache_Solr_service(); - $fixture->setHttpTransport($mockTransport); - $time = $fixture->ping(); - - $this->assertGreaterThan(0, $time); - } - - public function testPingReturnsFalse() - { - $expectedUrl = "http://localhost:8180/solr/admin/ping"; - $expectedTimeout = 2; - - // set a mock transport - $mockTransport = $this->getMockHttpTransportInterface(); - - // setup expected call and response - $mockTransport->expects($this->once()) - ->method('performHeadRequest') - ->with($this->equalTo($expectedUrl), $this->equalTo($expectedTimeout)) - ->will($this->returnValue(Apache_Solr_HttpTransport_ResponseTest::get0Response())); - - // call ping - $fixture = new Apache_Solr_service(); - $fixture->setHttpTransport($mockTransport); - - $this->assertFalse($fixture->ping()); - } - - public function testThreads() - { - $expectedUrl = "http://localhost:8180/solr/admin/threads?wt=json"; - $expectedTimeout = false; - - // set a mock transport - $mockTransport = $this->getMockHttpTransportInterface(); - - // setup expected call and response - $mockTransport->expects($this->once()) - ->method('performGetRequest') - ->with($this->equalTo($expectedUrl), $this->equalTo($expectedTimeout)) - ->will($this->returnValue(Apache_Solr_HttpTransport_ResponseTest::get200Response())); - - // call threads - $fixture = new Apache_Solr_service(); - $fixture->setHttpTransport($mockTransport); - $fixture->threads(); - } - - /** - * @expectedException Apache_Solr_HttpTransportException - */ - public function testThreads404() - { - $expectedUrl = "http://localhost:8180/solr/admin/threads?wt=json"; - $expectedTimeout = false; - - // set a mock transport - $mockTransport = $this->getMockHttpTransportInterface(); - - // setup expected call and response - $mockTransport->expects($this->once()) - ->method('performGetRequest') - ->with($this->equalTo($expectedUrl), $this->equalTo($expectedTimeout)) - ->will($this->returnValue(Apache_Solr_HttpTransport_ResponseTest::get404Response())); - - // call threads - $fixture = new Apache_Solr_service(); - $fixture->setHttpTransport($mockTransport); - $fixture->threads(); - } - - public function testAdd() - { - $postData = "does not have to be valid"; - - $expectedUrl = "http://localhost:8180/solr/update?wt=json"; - $expectedTimeout = false; - $expectedPostData = $postData; - $expectedContentType = "text/xml; charset=UTF-8"; // default for _sendRawPost - - // set a mock transport - $mockTransport = $this->getMockHttpTransportInterface(); - - // setup expected call and response - $mockTransport->expects($this->once()) - ->method('performPostRequest') - ->with($this->equalTo($expectedUrl), $this->equalTo($postData), $this->equalTo($expectedContentType), $this->equalTo($expectedTimeout)) - ->will($this->returnValue(Apache_Solr_HttpTransport_ResponseTest::get200Response())); - - // call add - $fixture = new Apache_Solr_service(); - $fixture->setHttpTransport($mockTransport); - $fixture->add($postData); - } - - /** - * @expectedException Apache_Solr_HttpTransportException - */ - public function testAdd400() - { - $postData = "does not have to be valid"; - - $expectedUrl = "http://localhost:8180/solr/update?wt=json"; - $expectedTimeout = false; - $expectedPostData = $postData; - $expectedContentType = "text/xml; charset=UTF-8"; // default for _sendRawPost - - // set a mock transport - $mockTransport = $this->getMockHttpTransportInterface(); - - // setup expected call and response - $mockTransport->expects($this->once()) - ->method('performPostRequest') - ->with($this->equalTo($expectedUrl), $this->equalTo($postData), $this->equalTo($expectedContentType), $this->equalTo($expectedTimeout)) - ->will($this->returnValue(Apache_Solr_HttpTransport_ResponseTest::get400Response())); - - // call add - $fixture = new Apache_Solr_service(); - $fixture->setHttpTransport($mockTransport); - $fixture->add($postData); - } - - public function testAddDocument() - { - // set a mock transport - $mockTransport = $this->getMockHttpTransportInterface(); - - // setup expected call and response - $mockTransport->expects($this->once()) - ->method('performPostRequest') - ->with( - // url - $this->equalTo('http://localhost:8180/solr/update?wt=json'), - - // raw post - $this->equalTo(''), - - // content type - $this->equalTo('text/xml; charset=UTF-8'), - - // timeout - $this->equalTo(false) - ) - ->will($this->returnValue(Apache_Solr_HttpTransport_ResponseTest::get200Response())); - - $fixture = new Apache_Solr_service(); - $fixture->setHttpTransport($mockTransport); - - $document = new Apache_Solr_Document(); - - $fixture->addDocument($document); - } - - public function testAddDocumentWithNonDefaultParameters() - { - // set a mock transport - $mockTransport = $this->getMockHttpTransportInterface(); - - // setup expected call and response - $mockTransport->expects($this->once()) - ->method('performPostRequest') - ->with( - // url - $this->equalTo('http://localhost:8180/solr/update?wt=json'), - - // raw post - $this->equalTo(''), - - // content type - $this->equalTo('text/xml; charset=UTF-8'), - - // timeout - $this->equalTo(false) - ) - ->will($this->returnValue(Apache_Solr_HttpTransport_ResponseTest::get200Response())); - - $fixture = new Apache_Solr_service(); - $fixture->setHttpTransport($mockTransport); - - $document = new Apache_Solr_Document(); - - $fixture->addDocument($document, true, false, false, 3600); - } - - public function testAddDocumentWithFields() - { - // set a mock transport - $mockTransport = $this->getMockHttpTransportInterface(); - - // setup expected call and response - $mockTransport->expects($this->once()) - ->method('performPostRequest') - ->with( - // url - $this->equalTo('http://localhost:8180/solr/update?wt=json'), - - // raw post - $this->equalTo('global unique idvaluevalue 1value 2'), - - // content type - $this->equalTo('text/xml; charset=UTF-8'), - - // timeout - $this->equalTo(false) - ) - ->will($this->returnValue(Apache_Solr_HttpTransport_ResponseTest::get200Response())); - - $fixture = new Apache_Solr_service(); - $fixture->setHttpTransport($mockTransport); - - $document = new Apache_Solr_Document(); - - $document->guid = "global unique id"; - $document->field = "value"; - $document->multivalue = array("value 1", "value 2"); - - $fixture->addDocument($document); - } - - public function testAddDocumentWithFieldBoost() - { - // set a mock transport - $mockTransport = $this->getMockHttpTransportInterface(); - - // setup expected call and response - $mockTransport->expects($this->once()) - ->method('performPostRequest') - ->with( - // url - $this->equalTo('http://localhost:8180/solr/update?wt=json'), - - // raw post - $this->equalTo('global unique idvaluevalue 1value 2'), - - // content type - $this->equalTo('text/xml; charset=UTF-8'), - - // timeout - $this->equalTo(false) - ) - ->will($this->returnValue(Apache_Solr_HttpTransport_ResponseTest::get200Response())); - - $fixture = new Apache_Solr_service(); - $fixture->setHttpTransport($mockTransport); - - $document = new Apache_Solr_Document(); - - $document->guid = "global unique id"; - - $document->field = "value"; - $document->setFieldBoost('field', 2); - - $document->multivalue = array("value 1", "value 2"); - $document->setFieldBoost('multivalue', 3); - - $fixture->addDocument($document); - } - - public function testAddDocumentWithDocumentBoost() - { - // set a mock transport - $mockTransport = $this->getMockHttpTransportInterface(); - - // setup expected call and response - $mockTransport->expects($this->once()) - ->method('performPostRequest') - ->with( - // url - $this->equalTo('http://localhost:8180/solr/update?wt=json'), - - // raw post - $this->equalTo('global unique idvalue'), - - // content type - $this->equalTo('text/xml; charset=UTF-8'), - - // timeout - $this->equalTo(false) - ) - ->will($this->returnValue(Apache_Solr_HttpTransport_ResponseTest::get200Response())); - - $fixture = new Apache_Solr_service(); - $fixture->setHttpTransport($mockTransport); - - $document = new Apache_Solr_Document(); - $document->setBoost(2); - - $document->guid = "global unique id"; - $document->field = "value"; - - $fixture->addDocument($document); - } - - public function testAddDocuments() - { - // set a mock transport - $mockTransport = $this->getMockHttpTransportInterface(); - - // setup expected call and response - $mockTransport->expects($this->once()) - ->method('performPostRequest') - ->with( - // url - $this->equalTo('http://localhost:8180/solr/update?wt=json'), - - // raw post - $this->equalTo(''), - - // content type - $this->equalTo('text/xml; charset=UTF-8'), - - // timeout - $this->equalTo(false) - ) - ->will($this->returnValue(Apache_Solr_HttpTransport_ResponseTest::get200Response())); - - $fixture = new Apache_Solr_service(); - $fixture->setHttpTransport($mockTransport); - - $documents = array( - new Apache_Solr_Document(), - new Apache_Solr_Document() - ); - - $fixture->addDocuments($documents); - } - - public function testAddDocumentsWithNonDefaultParameters() - { - // set a mock transport - $mockTransport = $this->getMockHttpTransportInterface(); - - // setup expected call and response - $mockTransport->expects($this->once()) - ->method('performPostRequest') - ->with( - // url - $this->equalTo('http://localhost:8180/solr/update?wt=json'), - - // raw post - $this->equalTo(''), - - // content type - $this->equalTo('text/xml; charset=UTF-8'), - - // timeout - $this->equalTo(false) - ) - ->will($this->returnValue(Apache_Solr_HttpTransport_ResponseTest::get200Response())); - - $fixture = new Apache_Solr_service(); - $fixture->setHttpTransport($mockTransport); - - $documents = array( - new Apache_Solr_Document(), - new Apache_Solr_Document() - ); - - $fixture->addDocuments($documents, true, false, false, 3600); - } - - public function testCommit() - { - // set a mock transport - $mockTransport = $this->getMockHttpTransportInterface(); - - // setup expected call and response - $mockTransport->expects($this->once()) - ->method('performPostRequest') - ->with( - // url - $this->equalTo('http://localhost:8180/solr/update?wt=json'), - - // raw post - $this->equalTo(''), - - // content type - $this->equalTo('text/xml; charset=UTF-8'), - - // timeout - $this->equalTo(3600) - ) - ->will($this->returnValue(Apache_Solr_HttpTransport_ResponseTest::get200Response())); - - $fixture = new Apache_Solr_Service(); - $fixture->setHttpTransport($mockTransport); - - $fixture->commit(); - } - - public function testCommitWithNonDefaultParameters() - { - // set a mock transport - $mockTransport = $this->getMockHttpTransportInterface(); - - // setup expected call and response - $mockTransport->expects($this->once()) - ->method('performPostRequest') - ->with( - // url - $this->equalTo('http://localhost:8180/solr/update?wt=json'), - - // raw post - $this->equalTo(''), - - // content type - $this->equalTo('text/xml; charset=UTF-8'), - - // timeout - $this->equalTo(7200) - ) - ->will($this->returnValue(Apache_Solr_HttpTransport_ResponseTest::get200Response())); - - $fixture = new Apache_Solr_Service(); - $fixture->setHttpTransport($mockTransport); - - $fixture->commit(true, false, false, 7200); - } - - public function testDelete() - { - $postData = "does not have to be valid"; - - $expectedUrl = "http://localhost:8180/solr/update?wt=json"; - $expectedTimeout = 3600; // default for delete - $expectedPostData = $postData; - $expectedContentType = "text/xml; charset=UTF-8"; // default for _sendRawPost - - // set a mock transport - $mockTransport = $this->getMockHttpTransportInterface(); - - // setup expected call and response - $mockTransport->expects($this->once()) - ->method('performPostRequest') - ->with($this->equalTo($expectedUrl), $this->equalTo($postData), $this->equalTo($expectedContentType), $this->equalTo($expectedTimeout)) - ->will($this->returnValue(Apache_Solr_HttpTransport_ResponseTest::get200Response())); - - // call add - $fixture = new Apache_Solr_service(); - $fixture->setHttpTransport($mockTransport); - $fixture->delete($postData); - } - - public function testDeleteById() - { - // set a mock transport - $mockTransport = $this->getMockHttpTransportInterface(); - - // setup expected call and response - $mockTransport->expects($this->once()) - ->method('performPostRequest') - ->will($this->returnValue(Apache_Solr_HttpTransport_ResponseTest::get200Response())); - - $fixture = new Apache_Solr_Service(); - $fixture->setHttpTransport($mockTransport); - - $fixture->deleteById("does not exist"); - } - - public function testDeleteByMultipleIds() - { - // set a mock transport - $mockTransport = $this->getMockHttpTransportInterface(); - - // setup expected call and response - $mockTransport->expects($this->once()) - ->method('performPostRequest') - ->will($this->returnValue(Apache_Solr_HttpTransport_ResponseTest::get200Response())); - - $fixture = new Apache_Solr_Service(); - $fixture->setHttpTransport($mockTransport); - - $fixture->deleteByMultipleIds(array(1, 2, 3)); - } - - public function testDeleteByQuery() - { - // set a mock transport - $mockTransport = $this->getMockHttpTransportInterface(); - - // setup expected call and response - $mockTransport->expects($this->once()) - ->method('performPostRequest') - ->will($this->returnValue(Apache_Solr_HttpTransport_ResponseTest::get200Response())); - - $fixture = new Apache_Solr_Service(); - $fixture->setHttpTransport($mockTransport); - - $fixture->deleteByQuery("*:*"); - } - - public function testExtracts() - { - $extractFile = __FILE__; - - $expectedUrl = "http://localhost:8180/solr/update/extract?resource.name=ServiceTest.php&wt=json&json.nl=map"; - $expectedPostData = file_get_contents($extractFile); - $expectedContentType = 'application/octet-stream'; // default for extract - $expectedTimeout = false; - - // set a mock transport - $mockTransport = $this->getMockHttpTransportInterface(); - - // setup expected call and response - $mockTransport->expects($this->once()) - ->method('performPostRequest') - ->with($this->equalTo($expectedUrl), $this->equalTo($expectedPostData), $this->equalTo($expectedContentType), $this->equalTo($expectedTimeout)) - ->will($this->returnValue(Apache_Solr_HttpTransport_ResponseTest::get200Response())); - - $fixture = new Apache_Solr_Service(); - $fixture->setHttpTransport($mockTransport); - - $fixture->extract($extractFile); - } - - /** - * @expectedException Apache_Solr_InvalidArgumentException - */ - public function testExtractWithInvalidParams() - { - $extractFile = __FILE__; - - // set a mock transport - $mockTransport = $this->getMockHttpTransportInterface(); - - $fixture = new Apache_Solr_Service(); - $fixture->setHttpTransport($mockTransport); - - $fixture->extract($extractFile, "invalid"); - } - - /** - * @expectedException Apache_Solr_InvalidArgumentException - */ - public function testExtractFromStringWithInvalidParams() - { - $extractFileData = "does not matter what it is"; - - // set a mock transport - $mockTransport = $this->getMockHttpTransportInterface(); - - $fixture = new Apache_Solr_Service(); - $fixture->setHttpTransport($mockTransport); - - $fixture->extractFromString($extractFileData, "invalid"); - } - - public function testExtractsWithNullParams() - { - $extractFile = __FILE__; - - $expectedUrl = "http://localhost:8180/solr/update/extract?resource.name=ServiceTest.php&wt=json&json.nl=map"; - $expectedPostData = file_get_contents($extractFile); - $expectedContentType = 'application/octet-stream'; // default for extract - $expectedTimeout = false; - - // set a mock transport - $mockTransport = $this->getMockHttpTransportInterface(); - - // setup expected call and response - $mockTransport->expects($this->once()) - ->method('performPostRequest') - ->with($this->equalTo($expectedUrl), $this->equalTo($expectedPostData), $this->equalTo($expectedContentType), $this->equalTo($expectedTimeout)) - ->will($this->returnValue(Apache_Solr_HttpTransport_ResponseTest::get200Response())); - - $fixture = new Apache_Solr_Service(); - $fixture->setHttpTransport($mockTransport); - - $fixture->extract($extractFile, null); - } - - /** - * @expectedException Apache_Solr_InvalidArgumentException - */ - public function testExtractWithEmptyFile() - { - $extractFile = "iDontExist.txt"; - - // set a mock transport - $mockTransport = $this->getMockHttpTransportInterface(); - - $fixture = new Apache_Solr_Service(); - $fixture->setHttpTransport($mockTransport); - - $fixture->extract($extractFile); - } - - public function testExtractsWithDocument() - { - $extractFile = __FILE__; - - $expectedUrl = "http://localhost:8180/solr/update/extract?resource.name=ServiceTest.php&wt=json&json.nl=map&boost.field=2&literal.field=literal+value"; - $expectedPostData = file_get_contents($extractFile); - $expectedContentType = 'application/octet-stream'; // default for extract - $expectedTimeout = false; - - // set a mock transport - $mockTransport = $this->getMockHttpTransportInterface(); - - // setup expected call and response - $mockTransport->expects($this->once()) - ->method('performPostRequest') - ->with($this->equalTo($expectedUrl), $this->equalTo($expectedPostData), $this->equalTo($expectedContentType), $this->equalTo($expectedTimeout)) - ->will($this->returnValue(Apache_Solr_HttpTransport_ResponseTest::get200Response())); - - $fixture = new Apache_Solr_Service(); - $fixture->setHttpTransport($mockTransport); - - $literals = new Apache_Solr_Document(); - $literals->field = "literal value"; - $literals->setFieldBoost('field', 2); - - $fixture->extract($extractFile, null, $literals); - } - - public function testExtractWithUrlDefers() - { - $extractUrl = "http://example.com"; - - $expectedUrl = "http://localhost:8180/solr/update/extract?resource.name=http%3A%2F%2Fexample.com&wt=json&json.nl=map"; - $expectedPostData = Apache_Solr_HttpTransport_ResponseTest::BODY_200; - $expectedContentType = 'application/octet-stream'; // default for extract - $expectedTimeout = false; - - // set a mock transport - $mockTransport = $this->getMockHttpTransportInterface(); - - // setup expected call and response - $mockTransport->expects($this->once()) - ->method('performGetRequest') - ->with( - $this->equalTo($extractUrl) - ) - ->will($this->returnValue(Apache_Solr_HttpTransport_ResponseTest::get200Response())); - - $mockTransport->expects($this->once()) - ->method('performPostRequest') - ->with( - $this->equalTo($expectedUrl), - $this->equalTo($expectedPostData), - $this->equalTo($expectedContentType), - $this->equalTo($expectedTimeout) - ) - ->will($this->returnValue(Apache_Solr_HttpTransport_ResponseTest::get200Response())); - - $fixture = new Apache_Solr_Service(); - $fixture->setHttpTransport($mockTransport); - - $fixture->extract($extractUrl); - } - - public function testExtractFromUrl() - { - $extractUrl = "http://example.com"; - - $expectedUrl = "http://localhost:8180/solr/update/extract?resource.name=http%3A%2F%2Fexample.com&wt=json&json.nl=map"; - $expectedPostData = Apache_Solr_HttpTransport_ResponseTest::BODY_200; - $expectedContentType = 'application/octet-stream'; // default for extract - $expectedTimeout = false; - - // set a mock transport - $mockTransport = $this->getMockHttpTransportInterface(); - - // setup expected call and response - $mockTransport->expects($this->once()) - ->method('performGetRequest') - ->with( - $this->equalTo($extractUrl) - ) - ->will($this->returnValue(Apache_Solr_HttpTransport_ResponseTest::get200Response())); - - $mockTransport->expects($this->once()) - ->method('performPostRequest') - ->with( - $this->equalTo($expectedUrl), - $this->equalTo($expectedPostData), - $this->equalTo($expectedContentType), - $this->equalTo($expectedTimeout) - ) - ->will($this->returnValue(Apache_Solr_HttpTransport_ResponseTest::get200Response())); - - $fixture = new Apache_Solr_Service(); - $fixture->setHttpTransport($mockTransport); - - $fixture->extractFromUrl($extractUrl); - } - - /** - * @expectedException Apache_Solr_InvalidArgumentException - */ - public function testExtractFromUrlWithInvalidParams() - { - $extractUrl = "http://example.com"; - - // set a mock transport - $mockTransport = $this->getMockHttpTransportInterface(); - - $fixture = new Apache_Solr_Service(); - $fixture->setHttpTransport($mockTransport); - - $fixture->extractFromUrl($extractUrl, "invalid"); - } - - public function testOptimize() - { - // set a mock transport - $mockTransport = $this->getMockHttpTransportInterface(); - - // setup expected call and response - $mockTransport->expects($this->once()) - ->method('performPostRequest') - ->will($this->returnValue(Apache_Solr_HttpTransport_ResponseTest::get200Response())); - - $fixture = new Apache_Solr_Service(); - $fixture->setHttpTransport($mockTransport); - - $fixture->optimize(); - } - - public function testSearch() - { - // set a mock transport - $mockTransport = $this->getMockHttpTransportInterface(); - - // setup expected call and response - $mockTransport->expects($this->once()) - ->method('performGetRequest') - ->will($this->returnValue(Apache_Solr_HttpTransport_ResponseTest::get200Response())); - - $fixture = new Apache_Solr_service(); - $fixture->setHttpTransport($mockTransport); - - $fixture->search("solr"); - } - - /** - * @expectedException Apache_Solr_InvalidArgumentException - */ - public function testSearchWithInvalidParams() - { - // set a mock transport - $mockTransport = $this->getMockHttpTransportInterface(); - - $fixture = new Apache_Solr_service(); - $fixture->setHttpTransport($mockTransport); - - $fixture->search("solr", 0, 10, "invalid"); - - $this->fail("Should have through InvalidArgumentException"); - } - - public function testSearchWithEmptyParams() - { - // set a mock transport - $mockTransport = $this->getMockHttpTransportInterface(); - - // setup expected call and response - $mockTransport->expects($this->once()) - ->method('performGetRequest') - ->will($this->returnValue(Apache_Solr_HttpTransport_ResponseTest::get200Response())); - - $fixture = new Apache_Solr_service(); - $fixture->setHttpTransport($mockTransport); - - $fixture->search("solr", 0, 10, null); - } - - public function testSearchWithPostMethod() - { - // set a mock transport - $mockTransport = $this->getMockHttpTransportInterface(); - - // setup expected call and response - $mockTransport->expects($this->once()) - ->method('performPostRequest') - ->will($this->returnValue(Apache_Solr_HttpTransport_ResponseTest::get200Response())); - - $fixture = new Apache_Solr_service(); - $fixture->setHttpTransport($mockTransport); - - $fixture->search("solr", 0, 10, array(), Apache_Solr_Service::METHOD_POST); - } - - /** - * @expectedException Apache_Solr_InvalidArgumentException - */ - public function testSearchWithInvalidMethod() - { - $fixture = new Apache_Solr_service(); - - $fixture->search("solr", 0, 10, array(), "INVALID METHOD"); - } -} \ No newline at end of file diff --git a/SolrPhpClient/tests/README b/SolrPhpClient/tests/README deleted file mode 100644 index 39ede2e9..00000000 --- a/SolrPhpClient/tests/README +++ /dev/null @@ -1,20 +0,0 @@ -Use the run.php script included in this directory to run all unit tests for the -Solr PHP Client library. Your system will require phpunit PEAR package - which -you can get install instructions for at: - -http://www.phpunit.de/ - -To generate the code coverage report, you will also need the XDebug pecl package -installed, typically this can be done with a simple: - -pecl install xdebug - -If you need more information on installation, then please see the official website: - -http://www.xdebug.org - -The scripts, configuration, and test files in this directory have been confirmed to -work with the following versions: - -phpunit: 3.3.16 -xdebug: 2.0.4 \ No newline at end of file diff --git a/SolrPhpClient/tests/phpunit.bootstrap.inc b/SolrPhpClient/tests/phpunit.bootstrap.inc deleted file mode 100644 index 237a0ec1..00000000 --- a/SolrPhpClient/tests/phpunit.bootstrap.inc +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - ../Apache - - ./run.php - - - - diff --git a/SolrPhpClient/tests/run.php b/SolrPhpClient/tests/run.php deleted file mode 100644 index b7445481..00000000 --- a/SolrPhpClient/tests/run.php +++ /dev/null @@ -1,42 +0,0 @@ -#! /usr/bin/php - + */ + +/** + * Additional code Copyright (c) 2011 by Peter Wolanin, and + * additional contributors. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program as the file LICENSE.txt; if not, please see + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. + */ + +/** + * Holds Key / Value pairs that represent a Solr Document along with any + * associated boost values. Field values can be accessed by direct dereferencing + * such as: + * + * @code + * $document->title = 'Something'; + * echo $document->title; + * @endcode + * + * Additionally, the field values can be iterated with foreach: + * + * @code + * foreach ($document as $fieldName => $fieldValue) { + * // ... + * } + * @endcode + */ +class SearchApiSolrDocument implements IteratorAggregate { + + /** + * Document boost value. + * + * @var float|false + */ + protected $documentBoost = FALSE; + + /** + * Document field values, indexed by name. + * + * @var array + */ + protected $fields = array(); + + /** + * Document field boost values, indexed by name. + * + * @var array + */ + protected $fieldBoosts = array(); + + /** + * Clears all boosts and fields from this document. + */ + public function clear() { + $this->documentBoost = FALSE; + + $this->fields = array(); + $this->fieldBoosts = array(); + } + + /** + * Gets the current document boost. + * + * @return float|false + * The current document boost, or FALSE if none is set. + */ + public function getBoost() { + return $this->documentBoost; + } + + /** + * Sets the document boost factor. + * + * @param float|false $boost + * FALSE for default boost, or a positive number for setting a document + * boost. + */ + public function setBoost($boost) { + $boost = (float) $boost; + + if ($boost > 0.0) { + $this->documentBoost = $boost; + } + else { + $this->documentBoost = FALSE; + } + } + + /** + * Adds a value to a multi-valued field + * + * NOTE: the solr XML format allows you to specify boosts PER value even + * though the underlying Lucene implementation only allows a boost per field. + * To remedy this, the final field boost value will be the product of all + * specified boosts on field values - this is similar to SolrJ's + * functionality. + * + * @code + * $doc = new ApacheSolrDocument(); + * $doc->addField('foo', 'bar', 2.0); + * $doc->addField('foo', 'baz', 3.0); + * // Resultant field boost will be 6! + * echo $doc->getFieldBoost('foo'); + * @endcode + * + * @param string $key + * The name of the field. + * @param $value + * The value to add for the field. + * @param float|false $boost + * FALSE for default boost, or a positive number for setting a field boost. + */ + public function addField($key, $value, $boost = FALSE) { + if (!isset($this->fields[$key])) { + // create holding array if this is the first value + $this->fields[$key] = array(); + } + else if (!is_array($this->fields[$key])) { + // move existing value into array if it is not already an array + $this->fields[$key] = array($this->fields[$key]); + } + + if ($this->getFieldBoost($key) === FALSE) { + // boost not already set, set it now + $this->setFieldBoost($key, $boost); + } + else if ((float) $boost > 0.0) { + // multiply passed boost with current field boost - similar to SolrJ implementation + $this->fieldBoosts[$key] *= (float) $boost; + } + + // add value to array + $this->fields[$key][] = $value; + } + + /** + * Gets information about a field stored in Solr. + * + * @param string $key + * The name of the field. + * + * @return array|false + * An associative array of info if the field exists, FALSE otherwise. + */ + public function getField($key) { + if (isset($this->fields[$key])) { + return array( + 'name' => $key, + 'value' => $this->fields[$key], + 'boost' => $this->getFieldBoost($key) + ); + } + + return FALSE; + } + + /** + * Sets a field value. + * + * Multi-valued fields should be set as arrays or via the addField() + * function which will automatically make sure the field is an array. + * + * @param string $key + * The name of the field. + * @param string|array $value + * The value to set for the field. + * @param float|false $boost + * FALSE for default boost, or a positive number for setting a field boost. + */ + public function setField($key, $value, $boost = FALSE) { + $this->fields[$key] = $value; + $this->setFieldBoost($key, $boost); + } + + /** + * Gets the currently set field boost for a document field. + * + * @param string $key + * The name of the field. + * + * @return float|false + * The currently set field boost, or FALSE if none was set. + */ + public function getFieldBoost($key) { + return isset($this->fieldBoosts[$key]) ? $this->fieldBoosts[$key] : FALSE; + } + + /** + * Sets the field boost for a document field. + * + * @param string $key + * The name of the field. + * @param float|false $boost + * FALSE for default boost, or a positive number for setting a field boost. + */ + public function setFieldBoost($key, $boost) { + $boost = (float) $boost; + + if ($boost > 0.0) { + $this->fieldBoosts[$key] = $boost; + } + else { + $this->fieldBoosts[$key] = FALSE; + } + } + + /** + * Returns all current field boosts, indexed by field name. + * + * @return array + * An associative array in the format $field_name => $field_boost. + */ + public function getFieldBoosts() { + return $this->fieldBoosts; + } + + /** + * Gets the names of all fields in this document. + * + * @return array + * The names of all fields in this document. + */ + public function getFieldNames() { + return array_keys($this->fields); + } + + /** + * Gets the values of all fields in this document. + * + * @return array + * The values of all fields in this document. + */ + public function getFieldValues() { + return array_values($this->fields); + } + + /** + * Implements IteratorAggregate::getIterator(). + * + * Implementing the IteratorAggregate interface allows the following usage: + * @code + * foreach ($document as $key => $value) { + * // ... + * } + * @endcode + * + * @return Traversable + * An iterator over this document's fields. + */ + public function getIterator() { + $arrayObject = new ArrayObject($this->fields); + + return $arrayObject->getIterator(); + } + + /** + * Magic getter for field values. + * + * @param string $key + * The name of the field. + * + * @return string|array|null + * The value that was set for the field. + */ + public function __get($key) { + return $this->fields[$key]; + } + + /** + * Magic setter for field values. + * + * Multi-valued fields should be set as arrays or via the addField() function + * which will automatically make sure the field is an array. + * + * @param string $key + * The name of the field. + * @param string|array $value + * The value to set for the field. + */ + public function __set($key, $value) { + $this->setField($key, $value); + } + + /** + * Magic isset for fields values. + * + * Do not call directly. Allows the following usage: + * @code + * isset($document->some_field); + * @endcode + * + * @param string $key + * The name of the field. + * + * @return bool + * Whether the given key is set in this document. + */ + public function __isset($key) { + return isset($this->fields[$key]); + } + + /** + * Magic unset for field values. + * + * Do not call directly. Allows the following usage: + * @code + * unset($document->some_field); + * @endcode + * + * @param string $key + * The name of the field. + */ + public function __unset($key) { + unset($this->fields[$key]); + unset($this->fieldBoosts[$key]); + } + + /** + * Create an XML fragment from this document. + * + * This string can then be used inside a Solr add call. + * + * @return string + * An XML formatted string for this document. + */ + public function toXml() { + $xml = 'documentBoost !== FALSE) { + $xml .= ' boost="' . $this->documentBoost . '"'; + } + + $xml .= '>'; + + foreach ($this->fields as $key => $value) { + $fieldBoost = $this->getFieldBoost($key); + $key = htmlspecialchars($key, ENT_COMPAT, 'UTF-8'); + + if (is_array($value)) { + foreach ($value as $multivalue) { + $xml .= ''; + } + } + else { + $xml .= ''; + } + } + + $xml .= ''; + + // Remove any control characters to avoid Solr XML parser exception. + return self::stripCtrlChars($xml); + } + + /** + * Sanitizes XML for sending to Solr. + * + * Replaces control (non-printable) characters that are invalid to Solr's XML + * parser with a space. + * + * @param string $string + * The string to sanitize. + * + * @return string + * A string safe for including in a Solr request. + */ + public static function stripCtrlChars($string) { + // See: http://w3.org/International/questions/qa-forms-utf-8.html + // Printable utf-8 does not include any of these chars below x7F + return preg_replace('@[\x00-\x08\x0B\x0C\x0E-\x1F]@', ' ', $string); + } +} \ No newline at end of file diff --git a/service.inc b/includes/service.inc similarity index 61% rename from service.inc rename to includes/service.inc index eb91e9ee..4455235f 100644 --- a/service.inc +++ b/includes/service.inc @@ -10,14 +10,47 @@ class SearchApiSolrService extends SearchApiAbstractService { */ const SOLR_DATE_FORMAT = 'Y-m-d\TH:i:s\Z'; + /** + * The connection class used by this service. + * + * Must implement SearchApiSolrConnectionInterface. + * + * @var string + */ + protected $connection_class = 'SearchApiSolrConnection'; + /** * A connection to the Solr server. * - * @var SearchApiSolrConnection + * @var SearchApiSolrConnectionInterface */ protected $solr; /** + * An array of all recognized types. + * + * Maps the type names to the prefixes used for identifying them in the Solr + * schema. + * + * @var array + */ + protected static $type_prefixes = array( + 'text' => 'tm', + 'tokens' => 'tm', + 'string' => 's', + 'integer' => 'i', + 'decimal' => 'f', + 'date' => 'd', + 'duration' => 'i', + 'boolean' => 'b', + 'uri' => 's', + 'location' => 'loc', + 'geohash' => 'geo', + ); + + /** + * Static cache for getFieldNames(). + * * @var array */ protected $fieldNames = array(); @@ -34,7 +67,7 @@ class SearchApiSolrService extends SearchApiAbstractService { /** * Saves whether a commit operation was already scheduled for this server. * - * @var boolean + * @var bool */ protected $commitScheduled = FALSE; @@ -45,22 +78,21 @@ class SearchApiSolrService extends SearchApiAbstractService { */ protected $request_handler = NULL; - public function __construct(SearchApiServer $server) { - parent::__construct($server); - } - + /** + * Overrides SearchApiAbstractService::configurationForm(). + */ public function configurationForm(array $form, array &$form_state) { if ($this->options) { // Editing this server - $url = 'http://' . $this->options['host'] . ':' . $this->options['port'] . $this->options['path']; $form['server_description'] = array( '#type' => 'item', '#title' => t('Solr server URI'), - '#description' => l($url, $url), + '#description' => $this->getServerLink(), ); } $options = $this->options + array( + 'scheme' => 'http', 'host' => 'localhost', 'port' => '8983', 'path' => '/solr', @@ -69,11 +101,49 @@ class SearchApiSolrService extends SearchApiAbstractService { 'excerpt' => FALSE, 'retrieve_data' => FALSE, 'highlight_data' => FALSE, - 'http_method' => Apache_Solr_Service::METHOD_POST, + 'http_method' => 'POST', + // Default to TRUE for new servers, but to FALSE for existing ones. + 'clean_ids' => $this->options ? FALSE : TRUE, 'autocorrect_spell' => TRUE, 'autocorrect_suggest_words' => TRUE, ); + if (!$options['clean_ids']) { + if (module_exists('advanced_help')) { + $variables['@url']= url('help/search_api_solr/README.txt'); + } + else { + $variables['@url']= url(drupal_get_path('module', 'search_api_solr') . '/README.txt'); + } + $description = t('Change Solr field names to be more compatible with advanced features. Doing this leads to re-indexing of all indexes on this server. See README.txt for details.', $variables); + $form['clean_ids_form'] = array( + '#type' => 'fieldset', + '#title' => t('Clean field identifiers'), + '#description' => $description, + '#collapsible' => TRUE, + ); + $form['clean_ids_form']['submit'] = array( + '#type' => 'submit', + '#value' => t('Switch to clean field identifiers'), + '#submit' => array('_search_api_solr_switch_to_clean_ids'), + ); + } + $form['clean_ids'] = array( + '#type' => 'value', + '#value' => $options['clean_ids'], + ); + + $form['scheme'] = array( + '#type' => 'select', + '#title' => t('HTTP protocol'), + '#description' => t('The HTTP protocol to use for sending queries.'), + '#default_value' => $options['scheme'], + '#options' => array( + 'http' => 'http', + 'https' => 'https', + ), + ); + $form['host'] = array( '#type' => 'textfield', '#title' => t('Solr host'), @@ -110,7 +180,7 @@ class SearchApiSolrService extends SearchApiAbstractService { $form['http']['http_pass'] = array( '#type' => 'password', '#title' => t('Password'), - '#default_value' => $options['http_pass'], + '#description' => t('If this field is left blank and the HTTP username is filled out, the current password will not be changed.'), ); $form['advanced'] = array( @@ -152,8 +222,8 @@ class SearchApiSolrService extends SearchApiAbstractService { '#description' => t('The HTTP method to use for sending queries. Usually, POST will work fine in all cases.'), '#default_value' => $options['http_method'], '#options' => array( - Apache_Solr_Service::METHOD_POST => 'POST', - Apache_Solr_Service::METHOD_GET => 'GET', + 'POST' => 'POST', + 'GET' => 'GET', ), ); @@ -181,12 +251,18 @@ class SearchApiSolrService extends SearchApiAbstractService { return $form; } + /** + * Overrides SearchApiAbstractService::configurationFormValidate(). + */ public function configurationFormValidate(array $form, array &$values, array &$form_state) { if (isset($values['port']) && (!is_numeric($values['port']) || $values['port'] < 0 || $values['port'] > 65535)) { form_error($form['port'], t('The port has to be an integer between 0 and 65535.')); } } + /** + * Overrides SearchApiAbstractService::configurationFormSubmit(). + */ public function configurationFormSubmit(array $form, array &$values, array &$form_state) { // Since the form is nested into another, we can't simply use #parents for // doing this array restructuring magic. (At least not without creating an @@ -195,46 +271,50 @@ class SearchApiSolrService extends SearchApiAbstractService { $values += $values['advanced']; $values += !empty($values['autocomplete']) ? $values['autocomplete'] : array(); unset($values['http'], $values['advanced'], $values['autocomplete']); + // Highlighting retrieved data only makes sense when we retrieve data. $values['highlight_data'] &= $values['retrieve_data']; + // For password fields, there is no default value, they're empty by default. + // Therefore we ignore empty submissions if the user didn't change either. + if ($values['http_pass'] === '' + && isset($this->options['http_user']) + && $values['http_user'] === $this->options['http_user']) { + $values['http_pass'] = $this->options['http_pass']; + } + parent::configurationFormSubmit($form, $values, $form_state); } + /** + * Overrides SearchApiAbstractService::supportsFeature(). + */ public function supportsFeature($feature) { - // Search API features. - $supported = array( + $supported = drupal_map_assoc(array( 'search_api_autocomplete', 'search_api_facets', 'search_api_facets_operator_or', + 'search_api_grouping', 'search_api_mlt', 'search_api_multi', 'search_api_spellcheck', 'search_api_data_type_location', 'search_api_data_type_geohash', - ); - - // Custom data types. - foreach (search_api_solr_get_dynamic_field_info() as $type => $info) { - $supported[] = 'search_api_data_type_' . $type; - } - - $supported = drupal_map_assoc($supported); + )); return isset($supported[$feature]); } /** - * View this server's settings. + * Overrides SearchApiAbstractService::viewSettings(). */ public function viewSettings() { $output = ''; $options = $this->options; - $url = 'http://' . $options['host'] . ':' . $options['port'] . $options['path']; $output .= "
\n
"; $output .= t('Solr server URI'); $output .= "
\n
"; - $output .= l($url, $url); + $output .= $this->getServerLink(); $output .= '
'; if ($options['http_user']) { $output .= "\n
"; @@ -250,24 +330,50 @@ class SearchApiSolrService extends SearchApiAbstractService { return $output; } + /** + * Returns a link to the Solr server, if the necessary options are set. + */ + public function getServerLink() { + if (!$this->options) { + return ''; + } + $host = $this->options['host']; + if ($host == 'localhost' && !empty($_SERVER['SERVER_NAME'])) { + $host = $_SERVER['SERVER_NAME']; + } + $url = $this->options['scheme'] . '://' . $host . ':' . $this->options['port'] . $this->options['path']; + return l($url, $url); + } + /** * Create a connection to the Solr server as configured in $this->options. */ protected function connect() { if (!$this->solr) { - if (!class_exists('Apache_Solr_Service')) { - throw new Exception(t('SolrPhpClient library not found! Please follow the instructions in search_api_solr/INSTALL.txt for installing the Solr search module.')); + if (!class_exists($this->connection_class)) { + throw new SearchApiException(t('Invalid class @class set as Solr connection class.', array('@class' => $this->connection_class))); + } + $options = $this->options + array('server' => $this->server->machine_name); + $this->solr = new $this->connection_class($options); + if (!($this->solr instanceof SearchApiSolrConnectionInterface)) { + $this->solr = NULL; + throw new SearchApiException(t('Invalid class @class set as Solr connection class.', array('@class' => $this->connection_class))); } - $this->solr = new SearchApiSolrConnection($this->options); } } + /** + * Overrides SearchApiAbstractService::addIndex(). + */ public function addIndex(SearchApiIndex $index) { if (module_exists('search_api_multi') && module_exists('search_api_views')) { views_invalidate_cache(); } } + /** + * Overrides SearchApiAbstractService::fieldsUpdated(). + */ public function fieldsUpdated(SearchApiIndex $index) { if (module_exists('search_api_multi') && module_exists('search_api_views')) { views_invalidate_cache(); @@ -275,6 +381,9 @@ class SearchApiSolrService extends SearchApiAbstractService { return TRUE; } + /** + * Overrides SearchApiAbstractService::removeIndex(). + */ public function removeIndex($index) { if (module_exists('search_api_multi') && module_exists('search_api_views')) { views_invalidate_cache(); @@ -292,6 +401,9 @@ class SearchApiSolrService extends SearchApiAbstractService { } } + /** + * Implements SearchApiServiceInterface::indexItems(). + */ public function indexItems(SearchApiIndex $index, array $items) { $documents = array(); $ret = array(); @@ -300,7 +412,7 @@ class SearchApiSolrService extends SearchApiAbstractService { foreach ($items as $id => $item) { try { - $doc = new Apache_Solr_Document(); + $doc = new SearchApiSolrDocument(); $doc->setField('id', $this->createId($index_id, $id)); $doc->setField('index_id', $index_id); $doc->setField('item_id', $id); @@ -320,30 +432,31 @@ class SearchApiSolrService extends SearchApiAbstractService { } } + // Let other modules alter documents before sending them to solr. + drupal_alter('search_api_solr_documents', $documents, $index, $items); + $this->alterSolrDocuments($documents, $index, $items); + if (!$documents) { return array(); } try { $this->connect(); - $response = $this->solr->addDocuments($documents); - if ($response->getHttpStatus() == 200) { - if (!empty($index->options['index_directly'])) { - $this->scheduleCommit(); - } - return $ret; + $this->solr->addDocuments($documents); + if (!empty($index->options['index_directly'])) { + $this->scheduleCommit(); } - throw new SearchApiException(t('HTTP status @status: @msg.', - array('@status' => $response->getHttpStatus(), '@msg' => $response->getHttpStatusMessage()))); + return $ret; } - catch (Exception $e) { + catch (SearchApiException $e) { watchdog_exception('search_api_solr', $e, "%type while indexing: !message in %function (line %line of %file)."); } return array(); } /** - * Creates an ID used as the unique identifier at the Solr server. This has to - * consist of both index and item ID. + * Creates an ID used as the unique identifier at the Solr server. + * + * This has to consist of both index and item ID. */ protected function createId($index_id, $item_id) { return "$index_id-$item_id"; @@ -352,8 +465,8 @@ class SearchApiSolrService extends SearchApiAbstractService { /** * Create a list of all indexed field names mapped to their Solr field names. * - * The special fields "search_api_id", "search_api_relevance", and "id" are - * also included. Any Solr fields that exist on search results are mapped back + * The special fields "search_api_id" and "search_api_relevance" are also + * included. Any Solr fields that exist on search results are mapped back to * to their local field names in the final result set. * * @see SearchApiSolrService::search() @@ -362,9 +475,8 @@ class SearchApiSolrService extends SearchApiAbstractService { if (!isset($this->fieldNames[$index->machine_name]) || $reset) { // This array maps "local property name" => "solr doc property name". $ret = array( - 'search_api_id' => 'ss_search_api_id', + 'search_api_id' => 'item_id', 'search_api_relevance' => 'score', - 'search_api_item_id' => 'item_id', ); // Add the names of any fields configured on the index. @@ -383,12 +495,16 @@ class SearchApiSolrService extends SearchApiAbstractService { } $inner_type = search_api_extract_inner_type($type); - $type_info = search_api_solr_get_dynamic_field_info($inner_type); - $pref = isset($type_info['prefix']) ? $type_info['prefix']: ''; - if (empty($type_info['always multiValued'])) { + $pref = isset(self::$type_prefixes[$inner_type]) ? self::$type_prefixes[$inner_type] : ''; + if ($pref != 'tm') { $pref .= $type == $inner_type ? 's' : 'm'; } - $name = $pref . '_' . $key; + if (!empty($this->options['clean_ids'])) { + $name = $pref . '_' . str_replace(':', '$', $key); + } + else { + $name = $pref . '_' . $key; + } $ret[$key] = $name; } @@ -404,11 +520,12 @@ class SearchApiSolrService extends SearchApiAbstractService { /** * Helper method for indexing. - * Add $field with field name $key to the document $doc. The format of $field + * + * Adds $value with field name $key to the document $doc. The format of $value * is the same as specified in SearchApiServiceInterface::indexItems(). */ - protected function addIndexField(Apache_Solr_Document $doc, $key, $value, $type, $multi_valued = FALSE) { - // Don't index empty values (i.e., when field is missing) + protected function addIndexField(SearchApiSolrDocument $doc, $key, $value, $type, $multi_valued = FALSE) { + // Don't index empty values (i.e., when field is missing). if (!isset($value)) { return; } @@ -451,12 +568,33 @@ class SearchApiSolrService extends SearchApiAbstractService { } /** - * Delete items from an index on this server. + * Applies custom modifications to indexed Solr documents. + * + * This method allows subclasses to easily apply custom changes before the + * documents are sent to Solr. The method is empty by default. + * + * @param array $documents + * An array of SearchApiSolrDocument objects ready to be indexed, generated + * from $items array. + * @param SearchApiIndex $index + * The search index for which items are being indexed. + * @param array $items + * An array of items being indexed. + * + * @see hook_search_api_solr_documents_alter() + */ + protected function alterSolrDocuments(array &$documents, SearchApiIndex $index, array $items) { + } + + /** + * Implements SearchApiServiceInterface::deleteItems(). * * This method has a custom, Solr-specific extension: + * * If $ids is a string other than "all", it is treated as a Solr query. All * items matching that Solr query are then deleted. If $index is additionally * specified, then only those items also lying on that index will be deleted. + * * It is up to the caller to ensure $ids is a valid query when the method is * called in this fashion. */ @@ -485,26 +623,32 @@ class SearchApiSolrService extends SearchApiAbstractService { } $this->scheduleCommit(); } - catch(Exception $e) { + catch(SearchApiException $e) { watchdog_exception('search_api_solr', $e, '%type while deleting items from server @server: !message in %function (line %line of %file).', array('@server' => $this->server->name)); } } + /** + * Implements SearchApiServiceInterface::search(). + */ public function search(SearchApiQueryInterface $query) { $time_method_called = microtime(TRUE); - // Reset request handler + // Reset request handler. $this->request_handler = NULL; - // Get field information + // Get field information. $index = $query->getIndex(); $fields = $this->getFieldNames($index); + // Get Solr connection. + $this->connect(); + $version = $this->solr->getSolrVersion(); - // Extract keys + // Extract keys. $keys = $query->getKeys(); if (is_array($keys)) { $keys = $this->flattenKeys($keys); } - // Set searched fields + // Set searched fields. $options = $query->getOptions(); $search_fields = $query->getFields(); // Get the index fields to be able to retrieve boosts. @@ -516,36 +660,42 @@ class SearchApiSolrService extends SearchApiAbstractService { $qf[] = $fields[$f] . $boost; } - // Extract filters + // Extract filters. $filter = $query->getFilter(); $fq = $this->createFilterQueries($filter, $fields, $index->options['fields']); $fq[] = 'index_id:' . $index->machine_name; - // Extract sort + // Extract sort. $sort = array(); - foreach ($query->getSort() as $f => $order) { - $f = $fields[$f]; + foreach ($query->getSort() as $field => $order) { + $f = $fields[$field]; if (substr($f, 0, 3) == 'ss_') { $f = 'sort_' . substr($f, 3); } $order = strtolower($order); - $sort[] = "$f $order"; + $sort[$field] = "$f $order"; } - // Get facet fields + // Get facet fields. $facets = $query->getOption('search_api_facets', array()); $facet_params = $this->getFacetParams($facets, $fields, $fq); - // Handle highlighting + // Handle highlighting. $highlight_params = $this->getHighlightParams($query); - // Handle More Like This query + // Handle More Like This query. $mlt = $query->getOption('search_api_mlt'); if ($mlt) { $mlt_params['qt'] = 'mlt'; // The fields to look for similarities in. $mlt_fl = array(); foreach($mlt['fields'] as $f) { + // Solr 4 has a bug which results in numeric fields not being supported + // in MLT queries. + // Date fields don't seem to be supported at all. + if ($fields[$f][0] === 'd' || ($version == 4 && in_array($fields[$f][0], array('i', 'f')))) { + continue; + } $mlt_fl[] = $fields[$f]; // For non-text fields, set minimum word length to 0. if (isset($index->options['fields'][$f]['type']) && !search_api_is_text_type($index->options['fields'][$f]['type'])) { @@ -553,22 +703,178 @@ class SearchApiSolrService extends SearchApiAbstractService { } } $mlt_params['mlt.fl'] = implode(',', $mlt_fl); - $keys = 'id:' . SearchApiSolrConnection::phrase($this->createId($index->machine_name, $mlt['id'])); + $id = $this->createId($index->machine_name, $mlt['id']); + $id = call_user_func(array($this->connection_class, 'phrase'), $id); + $keys = 'id:' . $id; } - // Set defaults + // Handle spatial filters. + if ($spatials = $query->getOption('search_api_location')) { + foreach ($spatials as $i => $spatial) { + if (empty($spatial['field']) || empty($spatial['lat']) || empty($spatial['lon'])) { + continue; + } + + unset($radius); + $field = $fields[$spatial['field']]; + $escaped_field = SearchApiSolrConnection::escapeFieldName($field); + $point = ((float) $spatial['lat']) . ',' . ((float) $spatial['lon']); + + // Prepare the filter settings. + if (isset($spatial['radius'])) { + $radius = (float) $spatial['radius']; + } + $spatial_method = 'geofilt'; + if (isset($spatial['method']) && in_array($spatial['method'], array('geofilt', 'bbox'))) { + $spatial_method = $spatial['method']; + } + + // Change the fq facet ranges to the correct fq. + foreach ($fq as $key => $value) { + // If the fq consists only of a filter on this field, replace it with + // a range. + $preg_field = preg_quote($escaped_field, '/'); + if (preg_match('/^' . $preg_field . ':\["?(\*|\d+(?:\.\d+)?)"? TO "?(\*|\d+(?:\.\d+)?)"?\]$/', $value, $m)) { + unset($fq[$key]); + if ($m[1] && is_numeric($m[1])) { + $min_radius = isset($min_radius) ? max($min_radius, $m[1]) : $m[1]; + } + if (is_numeric($m[2])) { + // Make the radius tighter accordingly. + $radius = isset($radius) ? min($radius, $m[2]) : $m[2]; + } + } + } + + // If either a radius was given in the option, or a filter was + // encountered, set a filter for the lowest value. If a lower boundary + // was set (too), we can only set a filter for that if the field name + // doesn't contains any colons. + if (isset($min_radius) && strpos($field, ':') === FALSE) { + $upper = isset($radius) ? " u=$radius" : ''; + $fq[] = "{!frange l=$min_radius$upper}geodist($field,$point)"; + } + elseif (isset($radius)) { + $fq[] = "{!$spatial_method pt=$point sfield=$field d=$radius}"; + } + + // Change sort on the field, if set (and not already changed). + if (isset($sort[$spatial['field']]) && substr($sort[$spatial['field']], 0, strlen($field)) === $field) { + if (strpos($field, ':') === FALSE) { + $sort[$spatial['field']] = str_replace($field, "geodist($field,$point)", $sort[$spatial['field']]); + } + else { + $link = l(t('edit server'), 'admin/config/search/search_api/server/' . $this->server->machine_name . '/edit'); + watchdog('search_api_solr', 'Location sort on field @field had to be ignored because unclean field identifiers are used.', array('@field' => $spatial['field']), WATCHDOG_WARNING, $link); + } + } + + // Change the facet parameters for spatial fields to return distance + // facets. + if (!empty($facets)) { + if (!empty($facet_params['facet.field'])) { + $facet_params['facet.field'] = array_diff($facet_params['facet.field'], array($field)); + } + foreach ($facets as $delta => $facet) { + if ($facet['field'] != $spatial['field']) { + continue; + } + $steps = $facet['limit'] > 0 ? $facet['limit'] : 5; + $step = (isset($radius) ? $radius : 100) / $steps; + for ($k = $steps - 1; $k > 0; --$k) { + $distance = $step * $k; + $key = "spatial-$delta-$distance"; + $facet_params['facet.query'][] = "{!$spatial_method pt=$point sfield=$field d=$distance key=$key}"; + } + foreach (array('limit', 'mincount', 'missing') as $setting) { + unset($facet_params["f.$field.facet.$setting"]); + } + } + } + } + } + // Normal sorting on location fields isn't possible. + foreach ($sort as $field => $sort_param) { + if (substr($sort_param, 0, 3) === 'loc') { + unset($sort[$field]); + } + } + + // Handle field collapsing / grouping. + $grouping = $query->getOption('search_api_grouping'); + if (!empty($grouping['use_grouping'])) { + $group_params['group'] = 'true'; + // We always want the number of groups returned so that we get pagers done + // right. + $group_params['group.ngroups'] = 'true'; + if (!empty($grouping['truncate'])) { + $group_params['group.truncate'] = 'true'; + } + if (!empty($grouping['group_facet'])) { + $group_params['group.facet'] = 'true'; + } + foreach ($grouping['fields'] as $collapse_field) { + $type = $index_fields[$collapse_field]['type']; + // Only single-valued fields are supported. + if ($version < 4) { + // For Solr 3.x, only string and boolean fields are supported. + if (search_api_is_list_type($type) || !search_api_is_text_type($type, array('string', 'boolean', 'uri'))) { + $warnings[] = t('Grouping is not supported for field @field. ' . + 'Only single-valued fields of type "String", "Boolean" or "URI" are supported.', + array('@field' => $index_fields[$collapse_field]['name'])); + continue; + } + } + else { + if (search_api_is_list_type($type) || search_api_is_text_type($type)) { + $warnings[] = t('Grouping is not supported for field @field. ' . + 'Only single-valued fields not indexed as "Fulltext" are supported.', + array('@field' => $index_fields[$collapse_field]['name'])); + continue; + } + } + $group_params['group.field'][] = $fields[$collapse_field]; + } + if (empty($group_params['group.field'])) { + unset($group_params); + } + else { + if (!empty($grouping['group_sort'])) { + foreach ($grouping['group_sort'] as $group_sort_field => $order) { + if (isset($fields[$group_sort_field])) { + $f = $fields[$group_sort_field]; + if (substr($f, 0, 3) == 'ss_') { + $f = 'sort_' . substr($f, 3); + } + $order = strtolower($order); + $group_params['group.sort'][] = $f . ' ' . $order; + } + } + if (!empty($group_params['group.sort'])) { + $group_params['group.sort'] = implode(', ', $group_params['group.sort']); + } + } + if (!empty($grouping['group_limit']) && ($grouping['group_limit'] != 1)) { + $group_params['group.limit'] = $grouping['group_limit']; + } + } + } + + // Set defaults. if (!$keys) { $keys = NULL; } - $offset = isset($options['offset']) ? $options['offset'] : 0; - $limit = isset($options['limit']) ? $options['limit'] : 1000000; - // Collect parameters + // Collect parameters. $params = array( 'fl' => 'item_id,score', 'qf' => $qf, 'fq' => $fq, ); + if (isset($options['offset'])) { + $params['start'] = $options['offset']; + } + $params['rows'] = isset($options['limit']) ? $options['limit'] : 1000000; if ($sort) { $params['sort'] = implode(', ', $sort); } @@ -584,40 +890,42 @@ class SearchApiSolrService extends SearchApiAbstractService { if (!empty($mlt_params['mlt.fl'])) { $params += $mlt_params; } + if (!empty($group_params)) { + $params += $group_params; + } if (!empty($this->options['retrieve_data'])) { $params['fl'] = '*,score'; } + // Retrieve http method from server options. + $http_method = !empty($this->options['http_method']) ? $this->options['http_method'] : 'POST'; + $call_args = array( - 'query' => &$keys, - 'offset' => &$offset, - 'limit' => &$limit, - 'params' => &$params, + 'query' => &$keys, + 'params' => &$params, + 'http_method' => &$http_method, ); if ($this->request_handler) { $this->setRequestHandler($this->request_handler, $call_args); } try { - // Send search request + // Send search request. $time_processing_done = microtime(TRUE); - $this->connect(); drupal_alter('search_api_solr_query', $call_args, $query); $this->preQuery($call_args, $query); - // Retrieve http method from server options. - $http_method = !empty($this->options['http_method']) ? $this->options['http_method'] : Apache_Solr_Service::METHOD_POST; - $response = $this->solr->search($keys, $offset, $limit, $params, $http_method); + $response = $this->solr->search($keys, $params, $http_method); $time_query_done = microtime(TRUE); - if ($response->getHttpStatus() != 200) { - throw new SearchApiException(t('The Solr server responded with status code @status: @msg.', - array('@status' => $response->getHttpStatus(), '@msg' => $response->getHttpStatusMessage()))); - } - - // Extract results + // Extract results. $results = $this->extractResults($query, $response); - // Extract facets + // Add warnings, if present. + if (!empty($warnings)) { + $results['warnings'] = isset($results['warnings']) ? array_merge($warnings, $results['warnings']) : $warnings; + } + + // Extract facets. if ($facets = $this->extractFacets($query, $response)) { $results['search_api_facets'] = $facets; } @@ -625,7 +933,7 @@ class SearchApiSolrService extends SearchApiAbstractService { drupal_alter('search_api_solr_search_results', $results, $query, $response); $this->postQuery($results, $query, $response); - // Compute performance + // Compute performance. $time_end = microtime(TRUE); $results['performance'] = array( 'complete' => $time_end - $time_method_called, @@ -636,7 +944,7 @@ class SearchApiSolrService extends SearchApiAbstractService { return $results; } - catch (Exception $e) { + catch (SearchApiException $e) { throw new SearchApiException(t('An error occurred while trying to search with Solr: @msg.', array('@msg' => $e->getMessage()))); } } @@ -644,8 +952,8 @@ class SearchApiSolrService extends SearchApiAbstractService { /** * Extract results from a Solr response. * - * @param Apache_Solr_Response $response - * A response object from SolrPhpClient. + * @param object $response + * A HTTP response object. * * @return array * An array with two keys: @@ -653,7 +961,7 @@ class SearchApiSolrService extends SearchApiAbstractService { * - results: An array of search results, as specified by * SearchApiQueryInterface::execute(). */ - protected function extractResults(SearchApiQueryInterface $query, Apache_Solr_Response $response) { + protected function extractResults(SearchApiQueryInterface $query, $response) { $index = $query->getIndex(); $fields = $this->getFieldNames($index); $field_options = $index->options['fields']; @@ -661,16 +969,41 @@ class SearchApiSolrService extends SearchApiAbstractService { // Set up the results array. $results = array(); $results['results'] = array(); + // Keep a copy of the response in the results so it's possible to extract + // further useful information out of it, if necessary. + $results['search_api_solr_response'] = $response; + // In some rare cases (e.g., MLT query with nonexistent ID) the response // will be NULL. - if (!isset($response->response)) { + if (!isset($response->response) && !isset($response->grouped)) { $results['result count'] = 0; return $results; } - $results['result count'] = $response->response->numFound; + + // If field collapsing has been enabled for this query, we need to process + // the results differently. + $grouping = $query->getOption('search_api_grouping'); + if (!empty($grouping['use_grouping']) && !empty($response->grouped)) { + $docs = array(); + $results['result count'] = 0; + foreach ($grouping['fields'] as $field) { + if (!empty($response->grouped->{$fields[$field]})) { + $results['result count'] += $response->grouped->{$fields[$field]}->ngroups; + foreach ($response->grouped->{$fields[$field]}->groups as $group) { + foreach ($group->doclist->docs as $doc) { + $docs[] = $doc; + } + } + } + } + } + else { + $results['result count'] = $response->response->numFound; + $docs = $response->response->docs; + } // Add each search result to the results array. - foreach ($response->response->docs as $doc) { + foreach ($docs as $doc) { // Blank result array. $result = array( 'id' => NULL, @@ -697,7 +1030,7 @@ class SearchApiSolrService extends SearchApiAbstractService { // We can find the item id and score in the special 'search_api_*' // properties. Mappings are provided for these properties in // SearchApiSolrService::getFieldNames(). - $result['id'] = $result['fields']['search_api_item_id']; + $result['id'] = $result['fields']['search_api_id']; $result['score'] = $result['fields']['search_api_relevance']; $solr_id = $this->createId($index->machine_name, $result['id']); @@ -727,7 +1060,7 @@ class SearchApiSolrService extends SearchApiAbstractService { * Will also use highlighted fields to replace retrieved field data, if the * corresponding option is set. */ - protected function getExcerpt(Apache_Solr_Response $response, $id, array &$fields, array $field_mapping) { + protected function getExcerpt($response, $id, array &$fields, array $field_mapping) { if (!isset($response->highlighting->$id)) { return FALSE; } @@ -747,9 +1080,9 @@ class SearchApiSolrService extends SearchApiAbstractService { } if (!empty($this->options['highlight_data'])) { foreach ($field_mapping as $search_api_property => $solr_property) { - if (substr($solr_property, 0, 2) == 't_' && !empty($response->highlighting->$id->$solr_property)) { + if (substr($solr_property, 0, 3) == 'tm_' && !empty($response->highlighting->$id->$solr_property)) { // Contrary to above, we here want to preserve HTML, so we just - // replace the [HIGHLIGHT] tags with the appropriate format here. + // replace the [HIGHLIGHT] tags with the appropriate format. $fields[$search_api_property] = $this->formatHighlighting($response->highlighting->$id->$solr_property); } } @@ -758,7 +1091,15 @@ class SearchApiSolrService extends SearchApiAbstractService { return $output; } - + /** + * Changes highlighting tags from our custom, HTML-safe ones to HTML. + * + * @param string|array $snippet + * The snippet(s) to format. + * + * @return string|array + * The snippet(s), properly formatted as HTML. + */ protected function formatHighlighting($snippet) { return preg_replace('#\[(/?)HIGHLIGHT\]#', '<$1strong>', $snippet); } @@ -766,23 +1107,27 @@ class SearchApiSolrService extends SearchApiAbstractService { /** * Extract facets from a Solr response. * - * @param Apache_Solr_Response $response + * @param object $response * A response object from SolrPhpClient. * * @return array * An array describing facets that apply to the current results. */ - protected function extractFacets(SearchApiQueryInterface $query, Apache_Solr_Response $response) { + protected function extractFacets(SearchApiQueryInterface $query, $response) { + $facets = array(); + + if (!isset($response->facet_counts)) { + return $facets; + } + + $index = $query->getIndex(); + $fields = $this->getFieldNames($index); + + $extract_facets = $query->getOption('search_api_facets', array()); + if (isset($response->facet_counts->facet_fields)) { - $index = $query->getIndex(); - $fields = $this->getFieldNames($index); - - $facets = array(); $facet_fields = $response->facet_counts->facet_fields; - $extract_facets = $query->getOption('search_api_facets'); - $extract_facets = ($extract_facets ? $extract_facets : array()); - foreach ($extract_facets as $delta => $info) { $field = $fields[$info['field']]; if (!empty($facet_fields->$field)) { @@ -790,15 +1135,18 @@ class SearchApiSolrService extends SearchApiAbstractService { $terms = $facet_fields->$field; if ($info['missing']) { // We have to correctly incorporate the "_empty_" term. - // This will ensure that the term with the least results is dropped, if the limit would be exceeded. - if (isset($terms->_empty_) && $terms->_empty_ < $min_count) { - unset($terms->_empty_); - } - else { - $terms = (array) $terms; - arsort($terms); - if (count($terms) > $info['limit']) { - array_pop($terms); + // This will ensure that the term with the least results is dropped, + // if the limit would be exceeded. + if (isset($terms->_empty_)) { + if ($terms->_empty_ < $min_count) { + unset($terms->_empty_); + } + else { + $terms = (array) $terms; + arsort($terms); + if ($info['limit'] > 0 && count($terms) > $info['limit']) { + array_pop($terms); + } } } } @@ -806,25 +1154,32 @@ class SearchApiSolrService extends SearchApiAbstractService { $terms = clone $terms; unset($terms->_empty_); } - $type = isset($index->options['fields'][$info['field']]['type']) ? $index->options['fields'][$info['field']]['type'] : 'string'; + $type = isset($index->options['fields'][$info['field']]['type']) ? search_api_extract_inner_type($index->options['fields'][$info['field']]['type']) : 'string'; foreach ($terms as $term => $count) { if ($count >= $min_count) { - if ($type == 'boolean') { + if ($term === '_empty_') { + $term = '!'; + } + elseif ($type == 'boolean') { if ($term == 'true') { - $term = 1; + $term = '"1"'; } elseif ($term == 'false') { - $term = 0; + $term = '"0"'; } } elseif ($type == 'date') { - $term = isset($term) ? strtotime($term) : NULL; + $term = $term ? '"' . strtotime($term) . '"' : NULL; + } + else { + $term = "\"$term\""; + } + if ($term) { + $facets[$delta][] = array( + 'filter' => $term, + 'count' => $count, + ); } - $term = $term === '_empty_' ? '!' : '"' . $term . '"'; - $facets[$delta][] = array( - 'filter' => $term, - 'count' => $count, - ); } } if (empty($facets[$delta])) { @@ -833,8 +1188,30 @@ class SearchApiSolrService extends SearchApiAbstractService { } } - return $facets; } + + if (isset($response->facet_counts->facet_queries)) { + if ($spatials = $query->getOption('search_api_location')) { + $queries = array(); + foreach ($response->facet_counts->facet_queries as $key => $count) { + if (!preg_match('/^spatial-(.*)-(\d+(?:\.\d+)?)$/', $key, $m)) { + continue; + } + if (empty($extract_facets[$m[1]])) { + continue; + } + $facet = $extract_facets[$m[1]]; + if ($count >= $facet['min_count']) { + $facets[$m[1]][] = array( + 'filter' => "[* {$m[2]}]", + 'count' => $count, + ); + } + } + } + } + + return $facets; } /** @@ -870,7 +1247,7 @@ class SearchApiSolrService extends SearchApiAbstractService { } else { $key = trim($key); - $key = SearchApiSolrConnection::phrase($key); + $key = call_user_func(array($this->connection_class, 'phrase'), $key); $k[] = $key; } } @@ -879,7 +1256,7 @@ class SearchApiSolrService extends SearchApiAbstractService { } // Formatting the keys into a Solr query can be a bit complex. The following - // code will produce that look like this: + // code will produce filters that look like this: // // #conjunction | #negation | return value // ---------------------------------------------------------------- @@ -891,17 +1268,17 @@ class SearchApiSolrService extends SearchApiAbstractService { // If there was just a single, unnested key, we can ignore all this. if (count($k) == 1 && empty($nested_expressions)) { $k = reset($k); - return $neg ? "-$k" : $k; + return $neg ? "*:* AND -$k" : $k; } if ($or) { if ($neg) { - return '-' . implode(' -', $k); + return '*:* AND -' . implode(' AND -', $k); } return '((' . implode(') OR (', $k) . '))'; } $k = implode(' ', $k); - return $neg ? "-($k)" : $k; + return $neg ? "*:* AND -($k)" : $k; } /** @@ -940,15 +1317,15 @@ class SearchApiSolrService extends SearchApiAbstractService { * and operator. */ protected function createFilterQuery($field, $value, $operator, $field_info) { - $field = SearchApiSolrConnection::escapeFieldName($field); + $field = call_user_func(array($this->connection_class, 'escapeFieldName'), $field); if ($value === NULL) { - return ($operator == '=' ? '-' : '') . "$field:[* TO *]"; + return ($operator == '=' ? '*:* AND -' : '') . "$field:[* TO *]"; } $value = trim($value); $value = $this->formatFilterValue($value, search_api_extract_inner_type($field_info['type'])); switch ($operator) { case '<>': - return "-($field:$value)"; + return "*:* AND -($field:$value)"; case '<': return "$field:{* TO $value}"; case '<=': @@ -979,7 +1356,7 @@ class SearchApiSolrService extends SearchApiAbstractService { $value = format_date($value, 'custom', self::SOLR_DATE_FORMAT, 'UTC'); break; } - return SearchApiSolrConnection::phrase($value); + return call_user_func(array($this->connection_class, 'phrase'), $value); } /** @@ -1004,7 +1381,7 @@ class SearchApiSolrService extends SearchApiAbstractService { // Check for the "or" operator. if (isset($info['operator']) && $info['operator'] === 'or') { // Remember that filters for this field should be tagged. - $escaped = SearchApiSolrConnection::escapeFieldName($fields[$info['field']]); + $escaped = call_user_func(array($this->connection_class, 'escapeFieldName'), $fields[$info['field']]); $taggedFields[$escaped] = "{!tag=$escaped}"; // Add the facet field. $facet_params['facet.field'][] = "{!ex=$escaped}$field"; @@ -1049,8 +1426,15 @@ class SearchApiSolrService extends SearchApiAbstractService { * * (The $query parameter currently isn't used and only here for the potential * sake of subclasses.) + * + * @param SearchApiQueryInterface|SearchApiMultiQueryInterface $query + * The query object, either for a normal Search API query or a multi-index + * query. + * + * @return array + * An array of parameters to be added to the Solr search request. */ - protected function getHighlightParams(SearchApiQueryInterface $query) { + protected function getHighlightParams($query) { $highlight_params = array(); if (!empty($this->options['excerpt']) || !empty($this->options['highlight_data'])) { @@ -1064,7 +1448,7 @@ class SearchApiSolrService extends SearchApiAbstractService { } if (!empty($this->options['highlight_data'])) { - $highlight_params['hl.fl'] = 't_*'; + $highlight_params['hl.fl'] = 'tm_*'; $highlight_params['hl.snippets'] = 1; $highlight_params['hl.fragsize'] = 0; if (!empty($this->options['excerpt'])) { @@ -1083,17 +1467,18 @@ class SearchApiSolrService extends SearchApiAbstractService { } /** - * Helper method for setting the request handler, and making necessary - * adjustments to the request parameters. + * Sets the request handler. + * + * This should also make the needed adjustments to the request parameters. * * @param $handler * Name of the handler to set. * @param array $call_args - * An associative array containing all four arguments to the - * Apache_Solr_Service::search() call ("query", "offset", "limit" and - * "params") as references. + * An associative array containing all three arguments to the + * SearchApiSolrConnectionInterface::search() call ("query", "params" and + * "method") as references. * - * @return boolean + * @return bool * TRUE iff this method invocation handled the given handler. This allows * subclasses to recognize whether the request handler was already set by * this method. @@ -1107,13 +1492,15 @@ class SearchApiSolrService extends SearchApiAbstractService { } /** - * Empty method to allow subclasses to apply custom changes before the query - * is sent to Solr. Works exactly like hook_search_api_solr_query_alter(). + * Empty method called before sending a search query to Solr. + * + * This allows subclasses to apply custom changes before the query is sent to + * Solr. Works exactly like hook_search_api_solr_query_alter(). * * @param array $call_args - * An associative array containing all four arguments to the - * Apache_Solr_Service::search() call ("query", "offset", "limit" and - * "params") as references. + * An associative array containing all three arguments to the + * SearchApiSolrConnectionInterface::search() call ("query", "params" and + * "method") as references. * @param SearchApiQueryInterface $query * The SearchApiQueryInterface object representing the executed search query. */ @@ -1129,10 +1516,10 @@ class SearchApiSolrService extends SearchApiAbstractService { * The results array that will be returned for the search. * @param SearchApiQueryInterface $query * The SearchApiQueryInterface object representing the executed search query. - * @param Apache_Solr_Response $response + * @param object $response * The response object returned by Solr. */ - protected function postQuery(array &$results, SearchApiQueryInterface $query, Apache_Solr_Response $response) { + protected function postQuery(array &$results, SearchApiQueryInterface $query, $response) { } // @@ -1140,28 +1527,7 @@ class SearchApiSolrService extends SearchApiAbstractService { // /** - * Get autocompletion suggestions for some user input. - * - * @param SearchApiQueryInterface $query - * A query representing the completed user input so far. - * @param SearchApiAutocompleteSearch $search - * An object containing details about the search the user is on, and - * settings for the autocompletion. - * @param string $incomplete_key - * The start of another fulltext keyword for the search, which should be - * completed. - * @param string $user_input - * The complete user input for the fulltext search keywords so far. - * - * @return array - * An array of suggestion. Each suggestion is either a simple string - * containing the whole suggested keywords, or an array containing the - * following keys: - * - prefix: For special suggestions, some kind of prefix describing them. - * - suggestion_prefix: A suggested prefix for the entered input. - * - user_input: The input entered by the user. Defaults to $user_input. - * - suggestion_suffix: A suggested suffix for the entered input. - * - results: If available, the estimated number of results for these keys. + * Implements SearchApiAutocompleteInterface::getAutocompleteSuggestions(). */ // Largely copied from the apachesolr_autocomplete module. public function getAutocompleteSuggestions(SearchApiQueryInterface $query, SearchApiAutocompleteSearch $search, $incomplete_key, $user_input) { @@ -1225,6 +1591,7 @@ class SearchApiSolrService extends SearchApiAbstractService { $params = array( 'qf' => $qf, 'fq' => $fq, + 'rows' => 0, 'facet' => 'true', 'facet.field' => $facet_fields, 'facet.prefix' => $incomp, @@ -1233,11 +1600,13 @@ class SearchApiSolrService extends SearchApiAbstractService { 'spellcheck' => (!isset($this->options['autocorrect_spell']) || $this->options['autocorrect_spell']) ? 'true' : 'false', 'spellcheck.count' => 1, ); + // Retrieve http method from server options. + $http_method = !empty($this->options['http_method']) ? $this->options['http_method'] : 'POST'; + $call_args = array( - 'query' => &$keys, - 'offset' => 0, - 'limit' => 0, - 'params' => &$params, + 'query' => &$keys, + 'params' => &$params, + 'http_method' => &$http_method, ); if ($this->request_handler) { $this->setRequestHandler($this->request_handler, $call_args); @@ -1249,12 +1618,7 @@ class SearchApiSolrService extends SearchApiAbstractService { $this->connect(); drupal_alter('search_api_solr_query', $call_args, $query); $this->preQuery($call_args, $query); - $response = $this->solr->search($keys, 0, 0, $params); - - if ($response->getHttpStatus() != 200) { - watchdog('search_api_solr', 'The Solr server responded with status code @status: @msg.', array('@status' => $response->getHttpStatus(), '@msg' => $response->getHttpStatusMessage()), WATCHDOG_WARNING, 'admin/config/search/search_api/server/' . $this->server->machine_name); - return array(); - } + $response = $this->solr->search($keys, $params, $http_method); if (!empty($response->spellcheck->suggestions)) { $replace = array(); @@ -1320,12 +1684,14 @@ class SearchApiSolrService extends SearchApiAbstractService { if (drupal_strtolower(substr($term, 0, $incomp_length)) == $incomp) { $suggestions[] = array( 'suggestion_suffix' => substr($term, $incomp_length), + 'term' => $term, 'results' => $count, ); } else { $suggestions[] = array( 'suggestion_suffix' => ' ' . $term, + 'term' => $term, 'results' => $count, ); } @@ -1333,7 +1699,7 @@ class SearchApiSolrService extends SearchApiAbstractService { } } } - catch (Exception $e) { + catch (SearchApiException $e) { watchdog_exception('search_api_solr', $e, "%type during autocomplete Solr query: !message in %function (line %line of %file).", array(), WATCHDOG_WARNING); } @@ -1353,40 +1719,20 @@ class SearchApiSolrService extends SearchApiAbstractService { // /** - * Create a query object for searching on this server. - * - * @param $options - * Associative array of options configuring this query. See - * SearchApiMultiQueryInterface::__construct(). - * - * @throws SearchApiException - * If the server is currently disabled. - * - * @return SearchApiMultiQueryInterface - * An object for searching this server. + * Implements SearchApiMultiServiceInterface::queryMultiple(). */ public function queryMultiple(array $options = array()) { return new SearchApiMultiQuery($this->server, $options); } /** - * Executes a search on the server represented by this object. - * - * @param SearchApiMultiQueryInterface $query - * The search query to execute. - * - * @throws SearchApiException - * If an error prevented the search from completing. - * - * @return array - * An associative array containing the search results, as required by - * SearchApiMultiQueryInterface::execute(). + * Implements SearchApiMultiServiceInterface::searchMultiple(). */ public function searchMultiple(SearchApiMultiQueryInterface $query) { $time_method_called = microtime(TRUE); // Get field information $solr_fields = array( - 'search_api_id' => 'ss_search_api_id', + 'search_api_id' => 'item_id', 'search_api_relevance' => 'score', 'search_api_multi_index' => 'index_id', ); @@ -1430,7 +1776,7 @@ class SearchApiSolrService extends SearchApiAbstractService { // Restrict search to searched indexes. $index_filter = array(); foreach ($query->getIndexes() as $index_id => $index) { - $index_filter[] = 'index_id:' . SearchApiSolrConnection::phrase($index_id); + $index_filter[] = 'index_id:' . call_user_func(array($this->connection_class, 'phrase'), $index_id); } $fq[] = implode(' OR ', $index_filter); @@ -1447,116 +1793,150 @@ class SearchApiSolrService extends SearchApiAbstractService { // Get facet fields $facets = $query->getOption('search_api_facets') ? $query->getOption('search_api_facets') : array(); - $facet_params = $this->getFacetParams($facets, $solr_fields); + $facet_params = $this->getFacetParams($facets, $solr_fields, $fq); + + // Handle highlighting. + $highlight_params = $this->getHighlightParams($query); // Set defaults if (!$keys) { $keys = NULL; } $options = $query->getOptions(); - $offset = isset($options['offset']) ? $options['offset'] : 0; - $limit = isset($options['limit']) ? $options['limit'] : 1000000; // Collect parameters $params = array( - 'qf' => $qf, 'fl' => 'item_id,index_id,score', + 'qf' => $qf, 'fq' => $fq, ); + if (isset($options['offset'])) { + $params['start'] = $options['offset']; + } + if (isset($options['limit'])) { + $params['rows'] = $options['limit']; + } if ($sort) { $params['sort'] = implode(', ', $sort); } if (!empty($facet_params['facet.field'])) { $params += $facet_params; } - try { - // Send search request - $time_processing_done = microtime(TRUE); - $this->connect(); - $call_args = array( - 'query' => &$keys, - 'offset' => &$offset, - 'limit' => &$limit, - 'params' => &$params, + if (!empty($highlight_params)) { + $params += $highlight_params; + } + + // Retrieve http method from server options. + $http_method = !empty($this->options['http_method']) ? $this->options['http_method'] : 'POST'; + + // Send search request + $time_processing_done = microtime(TRUE); + $this->connect(); + + $call_args = array( + 'query' => &$keys, + 'params' => &$params, + 'http_method' => &$http_method, + ); + drupal_alter('search_api_solr_multi_query', $call_args, $query); + + $response = $this->solr->search($keys, $params, $http_method); + $time_query_done = microtime(TRUE); + + // Extract results + $results = array(); + $results['result count'] = $response->response->numFound; + $results['results'] = array(); + $tmp = array(); + foreach ($response->response->docs as $id => $doc) { + $result = array( + 'id' => $doc->item_id, + 'index_id' => $doc->index_id, + 'score' => $doc->score, ); - drupal_alter('search_api_solr_multi_query', $call_args, $query); - - // Retrieve http method from server options. - $http_method = !empty($this->options['http_method']) ? $this->options['http_method'] : Apache_Solr_Service::METHOD_POST; - $response = $this->solr->search($keys, $offset, $limit, $params, $http_method); - $time_query_done = microtime(TRUE); - - if ($response->getHttpStatus() != 200) { - throw new SearchApiException(t('The Solr server responded with status code @status: @msg.', - array('@status' => $response->getHttpStatus(), '@msg' => $response->getHttpStatusMessage()))); + $solr_id = $this->createId($doc->index_id, $result['id']); + $excerpt = $this->getExcerpt($response, $solr_id, $tmp, array()); + if ($excerpt) { + $result['excerpt'] = $excerpt; } + $results['results'][$id] = $result; + } - // Extract results - $results = array(); - $results['result count'] = $response->response->numFound; - $results['results'] = array(); - $tmp = array(); - foreach ($response->response->docs as $id => $doc) { - $result = array( - 'id' => $doc->item_id, - 'index_id' => $doc->index_id, - 'score' => $doc->score, - ); - $excerpt = $this->getExcerpt($response, $id, $tmp, array()); - if ($excerpt) { - $result['excerpt'] = $excerpt; - } - $results['results'][$id] = $result; - } - - // Extract facets - if (isset($response->facet_counts->facet_fields)) { - $results['search_api_facets'] = array(); - $facet_fields = $response->facet_counts->facet_fields; - foreach ($facets as $delta => $info) { - $field = $this->getFacetField($solr_fields[$info['field']]); - if (!empty($facet_fields->$field)) { - $min_count = $info['min_count']; - $terms = $facet_fields->$field; - if ($info['missing']) { - // We have to correctly incorporate the "_empty_" term. - // This will ensure that the term with the least results is dropped, if the limit would be exceeded. - $terms = (array) $terms; - arsort($terms); - if (count($terms) > $info['limit']) { - array_pop($terms); + // Extract facets + if (isset($response->facet_counts->facet_fields)) { + $results['search_api_facets'] = array(); + $facet_fields = $response->facet_counts->facet_fields; + foreach ($facets as $delta => $info) { + $field = $solr_fields[$info['field']]; + if (!empty($facet_fields->$field)) { + $min_count = $info['min_count']; + $terms = $facet_fields->$field; + if ($info['missing']) { + // We have to correctly incorporate the "_empty_" term. + // This will ensure that the term with the least results is dropped, + // if the limit would be exceeded. + if (isset($terms->_empty_)) { + if ($terms->_empty_ < $min_count) { + unset($terms->_empty_); + } + else { + $terms = (array) $terms; + arsort($terms); + if ($info['limit'] > 0 && count($terms) > $info['limit']) { + array_pop($terms); + } } } - foreach ($terms as $term => $count) { - if ($count >= $min_count) { - $term = $term == '_empty_' ? '!' : '"' . $term . '"'; + } + elseif (isset($terms->_empty_)) { + $terms = clone $terms; + unset($terms->_empty_); + } + $type = isset($index->options['fields'][$info['field']]['type']) ? search_api_extract_inner_type($index->options['fields'][$info['field']]['type']) : 'string'; + foreach ($terms as $term => $count) { + if ($count >= $min_count) { + if ($term === '_empty_') { + $term = '!'; + } + elseif ($type == 'boolean') { + if ($term == 'true') { + $term = '"1"'; + } + elseif ($term == 'false') { + $term = '"0"'; + } + } + elseif ($type == 'date') { + $term = $term ? '"' . strtotime($term) . '"' : NULL; + } + else { + $term = "\"$term\""; + } + if ($term) { $results['search_api_facets'][$delta][] = array( 'filter' => $term, 'count' => $count, ); } } - if (empty($results['search_api_facets'][$delta]) || count($results['search_api_facets'][$delta]) <= 1) { - unset($results['search_api_facets'][$delta]); - } + } + if (empty($results['search_api_facets'][$delta])) { + unset($results['search_api_facets'][$delta]); } } } - - // Compute performance - $time_end = microtime(TRUE); - $results['performance'] = array( - 'complete' => $time_end - $time_method_called, - 'preprocessing' => $time_processing_done - $time_method_called, - 'execution' => $time_query_done - $time_processing_done, - 'postprocessing' => $time_end - $time_query_done, - ); - - return $results; - } - catch (Exception $e) { - throw new SearchApiException($e->getMessage()); } + + // Compute performance + $time_end = microtime(TRUE); + $results['performance'] = array( + 'complete' => $time_end - $time_method_called, + 'preprocessing' => $time_processing_done - $time_method_called, + 'execution' => $time_query_done - $time_processing_done, + 'postprocessing' => $time_end - $time_query_done, + ); + + return $results; } // @@ -1579,11 +1959,12 @@ class SearchApiSolrService extends SearchApiAbstractService { public function commit() { try { $this->connect(); - return $this->solr->commit(FALSE, FALSE, FALSE); + return $this->solr->commit(FALSE); } - catch (Exception $e) { - watchdog('search_api_solr', 'A commit operation for server @name failed: @msg.', - array('@name' => $this->server->machine_name, '@msg' => $e->getMessage()), WATCHDOG_WARNING); + catch (SearchApiException $e) { + watchdog_exception('search_api_solr', $e, + '%type while trying to commit on server @server: !message in %function (line %line of %file).', + array('@server' => $this->server->machine_name), WATCHDOG_WARNING); } } @@ -1601,7 +1982,30 @@ class SearchApiSolrService extends SearchApiAbstractService { } /** - * @return SearchApiSolrConnection + * Gets the Solr connection class used by this service. + * + * @return string + * The name of a class which implements SearchApiSolrConnectionInterface. + */ + public function getConnectionClass() { + return $this->connection_class; + } + + /** + * Sets the Solr connection class used by this service. + * + * @param string $class + * The name of a class which implements SearchApiSolrConnectionInterface. + */ + public function setConnectionClass($class) { + $this->connection_class = $class; + $this->solr = NULL; + } + + /** + * Gets the currently used Solr connection object. + * + * @return SearchApiSolrConnectionInterface * The solr connection object used by this server. */ public function getSolrConnection() { @@ -1612,33 +2016,42 @@ class SearchApiSolrService extends SearchApiAbstractService { /** * Get metadata about fields in the Solr/Lucene index. * - * @param boolean $reset - * Reload the cached data? + * @param int $num_terms + * Number of 'top terms' to return. + * + * @return array + * An array of SearchApiSolrField objects. + * + * @see SearchApiSolrConnectionInterface::getFields() */ - public function getFields($reset = FALSE) { - $cid = 'search_api_solr:fields:' . $this->server->machine_name; + public function getFields($num_terms = 0) { + $this->connect(); + return $this->solr->getFields($num_terms); + } - // If the data hasn't been retrieved before and we aren't refreshing it, try - // to get data from the cache. - if (!isset($this->fields) && !$reset) { - $cache = cache_get($cid); - if (isset($cache->data) && !$reset) { - $this->fields = $cache->data; - } + /** + * Retrieves a config file or file list from the Solr server. + * + * Uses the admin/file request handler. + * + * @param string|null $file + * (optional) The name of the file to retrieve. If the file is a directory, + * the directory contents are instead listed and returned. NULL represents + * the root config directory. + * + * @return object + * A HTTP response object containing either the file contents or a file list. + */ + public function getFile($file = NULL) { + $this->connect(); + + $file_servlet_name = constant($this->connection_class . '::FILE_SERVLET'); + + $params['contentType'] = 'text/xml;charset=utf-8'; + if ($file) { + $params['file'] = $file; } - - // If there was no data in the cache, or if we're refreshing the data, - // connect to the Solr server, retrieve schema information, and cache it. - if (!isset($this->fields) || $reset) { - $this->connect(); - $this->fields = array(); - foreach ($this->solr->getFields() as $name => $info) { - $this->fields[$name] = new SearchApiSolrField($info); - } - cache_set($cid, $this->fields); - } - - return $this->fields; + return $this->solr->makeServletRequest($file_servlet_name, $params); } } diff --git a/includes/solr_connection.inc b/includes/solr_connection.inc new file mode 100644 index 00000000..8a262122 --- /dev/null +++ b/includes/solr_connection.inc @@ -0,0 +1,901 @@ + + */ + +/** + * Additional code Copyright (c) 2008-2011 by Robert Douglass, James McKinney, + * Jacob Singh, Alejandro Garza, Peter Wolanin, and additional contributors. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program as the file LICENSE.txt; if not, please see + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. + */ + +/** + * Starting point for the Solr API. Represents a Solr server resource and has + * methods for pinging, adding, deleting, committing, optimizing and searching. + */ + +class SearchApiSolrConnection implements SearchApiSolrConnectionInterface { + + /** + * Defines how NamedLists should be formatted in the output. + * + * This specifically affects facet counts. Valid values are 'map' (default) or + * 'flat'. + */ + const NAMED_LIST_FORMAT = 'map'; + + /** + * Path to the ping servlet. + */ + const PING_SERVLET = 'admin/ping'; + + /** + * Path to the update servlet. + */ + const UPDATE_SERVLET = 'update'; + + /** + * Path to the search servlet. + */ + const SEARCH_SERVLET = 'select'; + + /** + * Path to the luke servlet. + */ + const LUKE_SERVLET = 'admin/luke'; + + /** + * Path to the system servlet. + */ + const SYSTEM_SERVLET = 'admin/system'; + + /** + * Path to the stats servlet. + */ + const STATS_SERVLET = 'admin/stats.jsp'; + + /** + * Path to the stats servlet for Solr 4.x servers. + */ + const STATS_SERVLET_4 = 'admin/mbeans?wt=xml&stats=true'; + + /** + * Path to the file servlet. + */ + const FILE_SERVLET = 'admin/file'; + + /** + * The options passed when creating this connection. + * + * @var array + */ + protected $options; + + /** + * The Solr server's URL. + * + * @var string + */ + protected $base_url; + + /** + * Cached URL to the update servlet. + * + * @var string + */ + protected $update_url; + + /** + * The HTTP method to use for search requests. + * + * @var string + */ + protected $method; + + /** + * HTTP Basic Authentication header to set for requests to the Solr server. + * + * @var string + */ + protected $http_auth; + + /** + * The stream context to use for requests to the Solr server. + * + * Defaults to NULL (= pass no context at all). + * + * @var string + */ + protected $stream_context; + + /** + * Cache for the metadata from admin/luke. + * + * Contains an array of response objects, keyed by the number of "top terms". + * + * @var array + * + * @see getLuke() + */ + protected $luke = array(); + + /** + * Cache for information about the Solr core. + * + * @var SimpleXMLElement + * + * @see getStats() + */ + protected $stats; + + /** + * Cache for system information. + * + * @var array + * + * @see getSystemInfo() + */ + protected $system_info; + + /** + * Flag that denotes whether to use soft commits for Solr 4.x. + * + * Defaults to FALSE. + * + * @var bool + */ + protected $soft_commit = FALSE; + + /** + * Implements SearchApiSolrConnectionInterface::__construct(). + * + * Valid options include: + * - scheme: Scheme of the base URL of the Solr server. Most probably "http" + * or "https". Defaults to "http". + * - host: The host name (or IP) of the Solr server. Defaults to + * "localhost". + * - port: The port of the Solr server. Defaults to 8983. + * - path: The base path to the Solr server. Defaults to "/solr/". + * - http_user: If both this and "http_pass" are set, will use this + * information to add basic HTTP authentication to all requests to the + * Solr server. Not set by default. + * - http_pass: See "http_user". + * - http_method: The HTTP method to use for searches. Can be either "GET" + * or "POST". Defaults to "POST". + */ + public function __construct(array $options) { + $options += array( + 'scheme' => 'http', + 'host' => 'localhost', + 'port' => 8983, + 'path' => 'solr', + 'http_user' => NULL, + 'http_pass' => NULL, + 'http_method' => 'POST', + ); + $this->options = $options; + + $path = '/' . trim($options['path'], '/') . '/'; + $this->base_url = $options['scheme'] . '://' . $options['host'] . ':' . $options['port'] . $path; + + // Make sure we always have a valid method set, default to POST. + $this->method = $options['http_method'] == 'GET' ? 'GET' : 'POST'; + + // Set HTTP Basic Authentication parameter, if login data was set. + if (strlen($options['http_user']) && strlen($options['http_pass'])) { + $this->http_auth = 'Basic ' . base64_encode($options['http_user'] . ':' . $options['http_pass']); + } + } + + /** + * Implements SearchApiSolrConnectionInterface::ping(). + */ + public function ping($timeout = 2) { + $start = microtime(TRUE); + + if ($timeout <= 0.0) { + $timeout = -1; + } + $pingUrl = $this->constructUrl(self::PING_SERVLET); + + // Attempt a HEAD request to the Solr ping url. + $options = array( + 'method' => 'HEAD', + 'timeout' => $timeout, + ); + $response = $this->makeHttpRequest($pingUrl, $options); + + if ($response->code == 200) { + // Add 1 µs to the ping time so we never return 0. + return (microtime(TRUE) - $start) + 1E-6; + } + else { + return FALSE; + } + } + + /** + * Implements SearchApiSolrConnectionInterface::setSoftCommit(). + */ + public function setSoftCommit($soft_commit) { + $this->soft_commit = (bool) $soft_commit; + } + + /** + * Implements SearchApiSolrConnectionInterface::getSoftCommit(). + */ + public function getSoftCommit() { + return $this->soft_commit; + } + + /** + * Implements SearchApiSolrConnectionInterface::setStreamContext(). + */ + public function setStreamContext($stream_context) { + $this->stream_context = $stream_context; + } + + /** + * Implements SearchApiSolrConnectionInterface::getStreamContext(). + */ + public function getStreamContext() { + return $this->stream_context; + } + + /** + * Computes the cache ID to use for this connection. + * + * @param $suffix + * (optional) A suffix to append to the string to make it unique. + * + * @return string|null + * The cache ID to use for this connection and usage; or NULL if no caching + * should take place. + */ + protected function getCacheId($suffix = '') { + if (!empty($this->options['server'])) { + $cid = $this->options['server']; + return $suffix ? "$cid:$suffix" : $cid; + } + } + + /** + * Call the /admin/system servlet to retrieve system information. + * + * Stores the retrieved information in $system_info. + * + * @see getSystemInfo() + */ + protected function setSystemInfo() { + $cid = $this->getCacheId(__FUNCTION__); + if ($cid) { + $cache = cache_get($cid, 'cache_search_api_solr'); + if ($cache) { + $this->system_info = json_decode($cache->data); + } + } + // Second pass to populate the cache if necessary. + if (empty($this->system_info)) { + $url = $this->constructUrl(self::SYSTEM_SERVLET, array('wt' => 'json')); + $response = $this->sendRawGet($url); + $this->system_info = json_decode($response->data); + if ($cid) { + cache_set($cid, $response->data, 'cache_search_api_solr'); + } + } + } + + /** + * Implements SearchApiSolrConnectionInterface::getSystemInfo(). + */ + public function getSystemInfo() { + if (!isset($this->system_info)) { + $this->setSystemInfo(); + } + return $this->system_info; + } + + /** + * Sets $this->luke with the metadata about the index from admin/luke. + */ + protected function setLuke($num_terms = 0) { + if (empty($this->luke[$num_terms])) { + $cid = $this->getCacheId(__FUNCTION__ . ":$num_terms"); + if ($cid) { + $cache = cache_get($cid, 'cache_search_api_solr'); + if (isset($cache->data)) { + $this->luke = $cache->data; + } + } + // Second pass to populate the cache if necessary. + if (empty($this->luke[$num_terms])) { + $params = array( + 'numTerms' => "$num_terms", + 'wt' => 'json', + 'json.nl' => self::NAMED_LIST_FORMAT, + ); + $url = $this->constructUrl(self::LUKE_SERVLET, $params); + $this->luke[$num_terms] = $this->sendRawGet($url); + if ($cid) { + cache_set($cid, $this->luke, 'cache_search_api_solr'); + } + } + } + } + + /** + * Implements SearchApiSolrConnectionInterface::getFields(). + */ + public function getFields($num_terms = 0) { + $fields = array(); + foreach ($this->getLuke($num_terms)->fields as $name => $info) { + $fields[$name] = new SearchApiSolrField($info); + } + return $fields; + } + + /** + * Implements SearchApiSolrConnectionInterface::getLuke(). + */ + public function getLuke($num_terms = 0) { + if (!isset($this->luke[$num_terms])) { + $this->setLuke($num_terms); + } + return $this->luke[$num_terms]; + } + + /** + * Implements SearchApiSolrConnectionInterface::getSolrVersion(). + */ + public function getSolrVersion() { + $system_info = $this->getSystemInfo(); + // Get our solr version number + if (isset($system_info->lucene->{'solr-spec-version'})) { + return $system_info->lucene->{'solr-spec-version'}[0]; + } + return 0; + } + + /** + * Stores information about the Solr core in $this->stats. + */ + protected function setStats() { + $data = $this->getLuke(); + $solr_version = $this->getSolrVersion(); + // Only try to get stats if we have connected to the index. + if (empty($this->stats) && isset($data->index->numDocs)) { + $cid = $this->getCacheId(__FUNCTION__); + if ($cid) { + $cache = cache_get($cid, 'cache_search_api_solr'); + if (isset($cache->data)) { + $this->stats = simplexml_load_string($cache->data); + } + } + // Second pass to populate the cache if necessary. + if (empty($this->stats)) { + if ($solr_version >= 4) { + $url = $this->constructUrl(self::STATS_SERVLET_4); + } + else { + $url = $this->constructUrl(self::STATS_SERVLET); + } + $response = $this->sendRawGet($url); + $this->stats = simplexml_load_string($response->data); + if ($this->env_id) { + cache_set($cid, $response->data, 'cache_search_api_solr'); + } + } + } + } + + /** + * Implements SearchApiSolrConnectionInterface::getStats(). + */ + public function getStats() { + if (!isset($this->stats)) { + $this->setStats(); + } + return $this->stats; + } + + /** + * Implements SearchApiSolrConnectionInterface::getStatsSummary(). + */ + public function getStatsSummary() { + $stats = $this->getStats(); + $solr_version = $this->getSolrVersion(); + + $summary = array( + '@pending_docs' => '', + '@autocommit_time_seconds' => '', + '@autocommit_time' => '', + '@deletes_by_id' => '', + '@deletes_by_query' => '', + '@deletes_total' => '', + '@schema_version' => '', + '@core_name' => '', + '@index_size' => '', + ); + + if (!empty($stats)) { + if ($solr_version <= 3) { + $docs_pending_xpath = $stats->xpath('//stat[@name="docsPending"]'); + $summary['@pending_docs'] = (int) trim(current($docs_pending_xpath)); + $max_time_xpath = $stats->xpath('//stat[@name="autocommit maxTime"]'); + $max_time = (int) trim(current($max_time_xpath)); + // Convert to seconds. + $summary['@autocommit_time_seconds'] = $max_time / 1000; + $summary['@autocommit_time'] = format_interval($max_time / 1000); + $deletes_id_xpath = $stats->xpath('//stat[@name="deletesById"]'); + $summary['@deletes_by_id'] = (int) trim(current($deletes_id_xpath)); + $deletes_query_xpath = $stats->xpath('//stat[@name="deletesByQuery"]'); + $summary['@deletes_by_query'] = (int) trim(current($deletes_query_xpath)); + $summary['@deletes_total'] = $summary['@deletes_by_id'] + $summary['@deletes_by_query']; + $schema = $stats->xpath('/solr/schema[1]'); + $summary['@schema_version'] = trim($schema[0]); + $core = $stats->xpath('/solr/core[1]'); + $summary['@core_name'] = trim($core[0]); + $size_xpath = $stats->xpath('//stat[@name="indexSize"]'); + $summary['@index_size'] = trim(current($size_xpath)); + } + else { + $system_info = $this->getSystemInfo(); + $docs_pending_xpath = $stats->xpath('//lst["stats"]/long[@name="docsPending"]'); + $summary['@pending_docs'] = (int) trim(current($docs_pending_xpath)); + $max_time_xpath = $stats->xpath('//lst["stats"]/str[@name="autocommit maxTime"]'); + $max_time = (int) trim(current($max_time_xpath)); + // Convert to seconds. + $summary['@autocommit_time_seconds'] = $max_time / 1000; + $summary['@autocommit_time'] = format_interval($max_time / 1000); + $deletes_id_xpath = $stats->xpath('//lst["stats"]/long[@name="deletesById"]'); + $summary['@deletes_by_id'] = (int) trim(current($deletes_id_xpath)); + $deletes_query_xpath = $stats->xpath('//lst["stats"]/long[@name="deletesByQuery"]'); + $summary['@deletes_by_query'] = (int) trim(current($deletes_query_xpath)); + $summary['@deletes_total'] = $summary['@deletes_by_id'] + $summary['@deletes_by_query']; + $schema = $system_info->core->schema; + $summary['@schema_version'] = $schema; + $core = $stats->xpath('//lst["core"]/str[@name="coreName"]'); + $summary['@core_name'] = trim(current($core)); + $size_xpath = $stats->xpath('//lst["core"]/str[@name="indexSize"]'); + $summary['@index_size'] = trim(current($size_xpath)); + } + } + + return $summary; + } + + /** + * Implements SearchApiSolrConnectionInterface::clearCache(). + */ + public function clearCache() { + if ($cid = $this->getCacheId()) { + cache_clear_all($cid, 'cache_search_api_solr', TRUE); + cache_clear_all($cid, 'cache_search_api_solr', TRUE); + } + $this->luke = array(); + $this->stats = NULL; + $this->system_info = NULL; + } + + /** + * Checks the reponse code and throws an exception if it's not 200. + * + * @param object $response + * A response object. + * + * @return object + * The passed response object. + * + * @throws SearchApiException + * If the object's HTTP status is not 200. + */ + protected function checkResponse($response) { + $code = (int) $response->code; + + if ($code != 200) { + if ($code >= 400 && $code != 403 && $code != 404) { + // Add details, like Solr's exception message. + $response->status_message .= $response->data; + } + throw new SearchApiException('"' . $code . '" Status: ' . $response->status_message); + } + + return $response; + } + + /** + * Implements SearchApiSolrConnectionInterface::makeServletRequest(). + */ + public function makeServletRequest($servlet, array $params = array(), array $options = array()) { + // Add default params. + $params += array( + 'wt' => 'json', + 'json.nl' => self::NAMED_LIST_FORMAT, + ); + + $url = $this->constructUrl($servlet, $params); + $response = $this->makeHttpRequest($url, $options); + + return $this->checkResponse($response); + } + + /** + * Central method for making a GET operation against this Solr Server + */ + protected function sendRawGet($url, array $options = array()) { + $options['method'] = 'GET'; + $response = $this->makeHttpRequest($url, $options); + + return $this->checkResponse($response); + } + + /** + * Central method for making a POST operation against this Solr Server + */ + protected function sendRawPost($url, array $options = array()) { + $options['method'] = 'POST'; + // Normally we use POST to send XML documents. + if (empty($options['headers']['Content-Type'])) { + $options['headers']['Content-Type'] = 'text/xml; charset=UTF-8'; + } + $response = $this->makeHttpRequest($url, $options); + + return $this->checkResponse($response); + } + + /** + * Sends an HTTP request to Solr. + * + * This is just a wrapper around drupal_http_request(). + */ + protected function makeHttpRequest($url, array $options = array()) { + if (empty($options['method']) || $options['method'] == 'GET' || $options['method'] == 'HEAD') { + // Make sure we are not sending a request body. + $options['data'] = NULL; + } + if ($this->http_auth) { + $options['headers']['Authorization'] = $this->http_auth; + } + if ($this->stream_context) { + $options['context'] = $this->stream_context; + } + + $result = drupal_http_request($url, $options); + + if (!isset($result->code) || $result->code < 0) { + $result->code = 0; + $result->status_message = 'Request failed'; + $result->protocol = 'HTTP/1.0'; + } + // Additional information may be in the error property. + if (isset($result->error)) { + $result->status_message .= ': ' . check_plain($result->error); + } + + if (!isset($result->data)) { + $result->data = ''; + $result->response = NULL; + } + else { + $response = json_decode($result->data); + if (is_object($response)) { + foreach ($response as $key => $value) { + $result->$key = $value; + } + } + } + + return $result; + } + + /** + * Implements SearchApiSolrConnectionInterface::escape(). + */ + public static function escape($value, $version = 0) { + $replacements = array(); + + $specials = array('+', '-', '&&', '||', '!', '(', ')', '{', '}', '[', ']', '^', '"', '~', '*', '?', ':', "\\"); + // Solr 4.x introduces regular expressions, making the slash also a special + // character. + if ($version >= 4) { + $specials[] = '/'; + } + + foreach ($specials as $special) { + $replacements[$special] = "\\$special"; + } + + return strtr($value, $replacements); + } + + /** + * Implements SearchApiSolrConnectionInterface::escapePhrase(). + */ + public static function escapePhrase($value) { + $replacements['"'] = '\"'; + $replacements["\\"] = "\\\\"; + return strtr($value, $replacements); + } + + /** + * Implements SearchApiSolrConnectionInterface::phrase(). + */ + public static function phrase($value) { + return '"' . self::escapePhrase($value) . '"'; + } + + /** + * Implements SearchApiSolrConnectionInterface::escapeFieldName(). + */ + public static function escapeFieldName($value) { + $value = str_replace(':', '\:', $value); + return $value; + } + + /** + * Returns the HTTP URL for a certain servlet on the Solr server. + * + * @param $servlet + * A string path to a Solr request handler. + * @param array $params + * Additional GET parameters to append to the URL. + * @param $added_query_string + * Additional query string to append to the URL. + * + * @return string + */ + protected function constructUrl($servlet, array $params = array(), $added_query_string = NULL) { + // PHP's built in http_build_query() doesn't give us the format Solr wants. + $query_string = $this->httpBuildQuery($params); + + if ($query_string) { + $query_string = '?' . $query_string; + if ($added_query_string) { + $query_string = $query_string . '&' . $added_query_string; + } + } + elseif ($added_query_string) { + $query_string = '?' . $added_query_string; + } + + return $this->base_url . $servlet . $query_string; + } + + /** + * Implements SearchApiSolrConnectionInterface::getBaseUrl(). + */ + public function getBaseUrl() { + return $this->base_url; + } + + /** + * Implements SearchApiSolrConnectionInterface::setBaseUrl(). + */ + public function setBaseUrl($url) { + $this->base_url = $url; + $this->update_url = NULL; + } + + /** + * Implements SearchApiSolrConnectionInterface::update(). + */ + public function update($rawPost, $timeout = FALSE) { + if (empty($this->update_url)) { + // Store the URL in an instance variable since many updates may be sent + // via a single instance of this class. + $this->update_url = $this->constructUrl(self::UPDATE_SERVLET, array('wt' => 'json')); + } + $options['data'] = $rawPost; + if ($timeout) { + $options['timeout'] = $timeout; + } + return $this->sendRawPost($this->update_url, $options); + } + + /** + * Implements SearchApiSolrConnectionInterface::addDocuments(). + */ + public function addDocuments(array $documents, $overwrite = NULL, $commitWithin = NULL) { + $attr = ''; + + if (isset($overwrite)) { + $attr .= ' overwrite="' . ($overwrite ? 'true"' : 'false"'); + } + if (isset($commitWithin)) { + $attr .= ' commitWithin="' . ((int) $commitWithin) . '"'; + } + + $rawPost = ""; + foreach ($documents as $document) { + if (is_object($document) && ($document instanceof SearchApiSolrDocument)) { + $rawPost .= $document->toXml(); + } + } + $rawPost .= ''; + + return $this->update($rawPost); + } + + /** + * Implements SearchApiSolrConnectionInterface::commit(). + */ + public function commit($waitSearcher = TRUE, $timeout = 3600) { + return $this->optimizeOrCommit('commit', $waitSearcher, $timeout); + } + + /** + * Implements SearchApiSolrConnectionInterface::deleteById(). + */ + public function deleteById($id, $timeout = 3600) { + return $this->deleteByMultipleIds(array($id), $timeout); + } + + /** + * Implements SearchApiSolrConnectionInterface::deleteByMultipleIds(). + */ + public function deleteByMultipleIds(array $ids, $timeout = 3600) { + $rawPost = ''; + + foreach ($ids as $id) { + $rawPost .= '' . htmlspecialchars($id, ENT_NOQUOTES, 'UTF-8') . ''; + } + $rawPost .= ''; + + return $this->update($rawPost, $timeout); + } + + /** + * Implements SearchApiSolrConnectionInterface::deleteByQuery(). + */ + public function deleteByQuery($rawQuery, $timeout = 3600) { + $rawPost = '' . htmlspecialchars($rawQuery, ENT_NOQUOTES, 'UTF-8') . ''; + + return $this->update($rawPost, $timeout); + } + + /** + * Implements SearchApiSolrConnectionInterface::optimize(). + */ + public function optimize($waitSearcher = TRUE, $timeout = 3600) { + return $this->optimizeOrCommit('optimize', $waitSearcher, $timeout); + } + + /** + * Sends an commit or optimize command to the Solr server. + * + * Will be synchronous unless $waitSearcher is set to FALSE. + * + * @param $type + * Either "commit" or "optimize". + * @param $waitSearcher + * (optional) Wait until a new searcher is opened and registered as the main + * query searcher, making the changes visible. Defaults to true. + * @param $timeout + * Seconds to wait until timing out with an exception. Defaults to an hour. + * + * @return + * A response object. + * + * @throws SearchApiException + * If an error occurs during the service call. + */ + protected function optimizeOrCommit($type, $waitSearcher = TRUE, $timeout = 3600) { + $waitSearcher = $waitSearcher ? '' : ' waitSearcher="false"'; + + if ($this->getSolrVersion() <= 3) { + $rawPost = "<$type$waitSearcher />"; + } + else { + $softCommit = ($this->soft_commit) ? ' softCommit="true"' : ''; + $rawPost = "<$type$waitSearcher$softCommit />"; + } + + $response = $this->update($rawPost, $timeout); + $this->clearCache(); + + return $response; + } + + /** + * Like PHP's built in http_build_query(), but uses rawurlencode() and no [] for repeated params. + */ + protected function httpBuildQuery(array $query, $parent = '') { + $params = array(); + + foreach ($query as $key => $value) { + $key = ($parent ? $parent : rawurlencode($key)); + + // Recurse into children. + if (is_array($value)) { + $params[] = $this->httpBuildQuery($value, $key); + } + // If a query parameter value is NULL, only append its key. + elseif (!isset($value)) { + $params[] = $key; + } + else { + $params[] = $key . '=' . rawurlencode($value); + } + } + + return implode('&', $params); + } + + /** + * Implements SearchApiSolrConnectionInterface::search(). + */ + public function search($query = NULL, array $params = array(), $method = 'GET') { + // Always use JSON. See + // http://code.google.com/p/solr-php-client/issues/detail?id=6#c1 for + // reasoning. + $params['wt'] = 'json'; + // Additional default params. + $params += array( + 'json.nl' => self::NAMED_LIST_FORMAT, + ); + if ($query) { + $params['q'] = $query; + } + // PHP's built-in http_build_query() doesn't give us the format Solr wants. + $queryString = $this->httpBuildQuery($params); + + if ($this->method == 'GET') { + $searchUrl = $this->constructUrl(self::SEARCH_SERVLET, array(), $queryString); + return $this->sendRawGet($searchUrl); + } + else if ($this->method == 'POST') { + $searchUrl = $this->constructUrl(self::SEARCH_SERVLET); + $options['data'] = $queryString; + $options['headers']['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8'; + return $this->sendRawPost($searchUrl, $options); + } + } +} diff --git a/includes/solr_connection.interface.inc b/includes/solr_connection.interface.inc new file mode 100644 index 00000000..df30adef --- /dev/null +++ b/includes/solr_connection.interface.inc @@ -0,0 +1,365 @@ +field; + } + + /** + * Gets the type of the Solr field, according to the Solr schema. * * Note that field types like "text", "boolean", and "date" are conventions, * but their presence and behavior are entirely determined by the particular @@ -63,7 +73,7 @@ class SearchApiSolrField { } /** - * Get an array of field properties. + * Gets an array of field properties. * * @return array * An array of properties describing the solr schema. The array keys are @@ -80,7 +90,7 @@ class SearchApiSolrField { } /** - * Get the "dynamic base" of this field. + * Gets the "dynamic base" of this field. * * This typically looks like 'ss_*, and is used to aggregate fields based on * "hungarian" naming conventions. @@ -93,12 +103,12 @@ class SearchApiSolrField { } /** - * Determine whether this field may be suitable for use as a key field. + * Determines whether this field may be suitable for use as a key field. * * Unfortunately, it seems like the best way to find an actual uniqueKey field * according to Solr is to examine the Solr core's schema.xml. * - * @return boolean + * @return bool * Whether the field is suitable for use as a key. */ public function isPossibleKey() { @@ -109,14 +119,14 @@ class SearchApiSolrField { } /** - * Determine whether a field is suitable for sorting. + * Determines whether a field is suitable for sorting. * * In order for a field to yield useful sorted results in Solr, it must be * indexed, not multivalued, and not tokenized. It's ok if a field is * tokenized and yields only one token, but there's no general way to check * for that. * - * @return boolean + * @return bool * Whether the field is suitable for sorting. */ public function isSortable() { @@ -126,60 +136,146 @@ class SearchApiSolrField { } /** - * The following functions return information about specific properties of this field. + * Determines whether this field is indexed. * - * @return boolean + * @return bool + * TRUE if the field is indexed, FALSE otherwise. */ public function isIndexed() { $this->getSchema(); return isset($this->schema['I']); } + + /** + * Determines whether this field is tokenized. + * + * @return bool + * TRUE if the field is tokenized, FALSE otherwise. + */ public function isTokenized() { $this->getSchema(); return isset($this->schema['T']); } + + /** + * Determines whether this field is stored. + * + * @return bool + * TRUE if the field is stored, FALSE otherwise. + */ public function isStored() { $this->getSchema(); return isset($this->schema['S']); } + + /** + * Determines whether this field is multi-valued. + * + * @return bool + * TRUE if the field is multi-valued, FALSE otherwise. + */ public function isMultivalued() { $this->getSchema(); return isset($this->schema['M']); } + + /** + * Determines whether this field has stored term vectors. + * + * @return bool + * TRUE if the field has stored term vectors, FALSE otherwise. + */ public function isTermVectorStored() { $this->getSchema(); return isset($this->schema['V']); } + + /** + * Determines whether this field has the "termOffsets" option set. + * + * @return bool + * TRUE if the field has the "termOffsets" option set, FALSE otherwise. + */ public function isStoreOffsetWithTermVector() { $this->getSchema(); return isset($this->schema['o']); } + + /** + * Determines whether this field has the "termPositions" option set. + * + * @return bool + * TRUE if the field has the "termPositions" option set, FALSE otherwise. + */ public function isStorePositionWithTermVector() { $this->getSchema(); return isset($this->schema['p']); } + + /** + * Determines whether this field omits norms when indexing. + * + * @return bool + * TRUE if the field omits norms, FALSE otherwise. + */ public function isOmitNorms() { $this->getSchema(); return isset($this->schema['O']); } + + /** + * Determines whether this field is lazy-loaded. + * + * @return bool + * TRUE if the field is lazy-loaded, FALSE otherwise. + */ public function isLazy() { $this->getSchema(); return isset($this->schema['L']); } + + /** + * Determines whether this field is binary. + * + * @return bool + * TRUE if the field is binary, FALSE otherwise. + */ public function isBinary() { $this->getSchema(); return isset($this->schema['B']); } + + /** + * Determines whether this field is compressed. + * + * @return bool + * TRUE if the field is compressed, FALSE otherwise. + */ public function isCompressed() { $this->getSchema(); return isset($this->schema['C']); } + + /** + * Determines whether this field sorts missing entries first. + * + * @return bool + * TRUE if the field sorts missing entries first, FALSE otherwise. + */ public function isSortMissingFirst() { $this->getSchema(); return isset($this->schema['f']); } + + /** + * Determines whether this field sorts missing entries last. + * + * @return bool + * TRUE if the field sorts missing entries last, FALSE otherwise. + */ public function isSortMissingLast() { $this->getSchema(); return isset($this->schema['l']); } + } diff --git a/includes/solr_httptransport.inc b/includes/solr_httptransport.inc deleted file mode 100644 index bf6f9c99..00000000 --- a/includes/solr_httptransport.inc +++ /dev/null @@ -1,100 +0,0 @@ -http_auth = $http_auth; - } - - /** - * Perform a GET HTTP operation with an optional timeout and return the response - * contents, use getLastResponseHeaders to retrieve HTTP headers - * - * @param string $url - * @param float $timeout - * @return Apache_Solr_HttpTransport_Response HTTP response - */ - public function performGetRequest($url, $timeout = false) { - return $this->performHttpRequest('GET', $url, $timeout); - } - - /** - * Perform a HEAD HTTP operation with an optional timeout and return the response - * headers - NOTE: head requests have no response body - * - * @param string $url - * @param float $timeout - * @return Apache_Solr_HttpTransport_Response HTTP response - */ - public function performHeadRequest($url, $timeout = false) { - return $this->performHttpRequest('HEAD', $url, $timeout); - } - - /** - * Perform a POST HTTP operation with an optional timeout and return the response - * contents, use getLastResponseHeaders to retrieve HTTP headers - * - * @param string $url - * @param string $rawPost - * @param string $contentType - * @param float $timeout - * @return Apache_Solr_HttpTransport_Response HTTP response - */ - public function performPostRequest($url, $rawPost, $contentType, $timeout = false) { - return $this->performHttpRequest('POST', $url, $timeout, $rawPost, $contentType); - } - - /** - * Helper method for making an HTTP request. - */ - protected function performHttpRequest($method, $url, $timeout, $rawPost = NULL, $contentType = NULL) { - $options = array( - 'method' => $method, - 'timeout' => $timeout && $timeout > 0 ? $timeout : $this->getDefaultTimeout(), - 'headers' => array(), - ); - - if ($this->http_auth) { - $options['headers']['Authorization'] = $this->http_auth; - } - if ($timeout) { - $options['timeout'] = $timeout; - } - if ($rawPost) { - $options['data'] = $rawPost; - } - if ($contentType) { - $options['headers']['Content-Type'] = $contentType; - } - - $response = drupal_http_request($url, $options); - - $type = isset($response->headers['content-type']) ? $response->headers['content-type'] : 'text/xml'; - $body = isset($response->data) ? $response->data : NULL; - return new Apache_Solr_HttpTransport_Response($response->code, $type, $body); - } - -} diff --git a/includes/spellcheck.inc b/includes/spellcheck.inc index 3e89ce00..58875b3f 100644 --- a/includes/spellcheck.inc +++ b/includes/spellcheck.inc @@ -11,15 +11,15 @@ class SearchApiSpellcheckSolr extends SearchApiSpellcheck { /** - * Constructor. + * Constructs a SearchApiSpellcheckSolr object. * - * If solr has returned spelling suggestion then loop through them and add + * If Solr has returned spelling suggestion then loop through them and add * them to this spellcheck service. * - * @param Apache_Solr_Response $response + * @param object $response * The Solr response object. */ - function __construct(Apache_Solr_Response $response) { + function __construct($response) { if (isset($response->spellcheck->suggestions)) { $suggestions = $response->spellcheck->suggestions; foreach ($suggestions as $word => $data) { diff --git a/search_api_solr.admin.inc b/search_api_solr.admin.inc new file mode 100644 index 00000000..bab6573a --- /dev/null +++ b/search_api_solr.admin.inc @@ -0,0 +1,62 @@ +' . t('List of configuration files found:') . ''; + + try { + // Retrieve the list of available files. + $files_list = search_api_solr_server_get_files($server); + + if (empty($files_list)) { + $form['info']['#markup'] = t('No files found.'); + return $form; + } + + $form['files'] = array( + '#type' => 'vertical_tabs', + ); + + // Generate a fieldset for each file. + foreach ($files_list as $file_name => $file_info) { + $file_date = format_date(strtotime($file_info['modified'])); + $escaped_file_name = check_plain($file_name); + + $form['files'][$file_name] = array( + '#title' => $escaped_file_name, + '#type' => 'fieldset', + ); + + $data = '

' . $escaped_file_name . '

'; + $data .= '

' . t('Last modified: @time.', array('@time' => $file_date)) . '

'; + + if ($file_info['size'] > 0) { + $file_data = $server->getFile($file_name); + $data .= '
' . check_plain($file_data->data) . '
'; + } + else { + $data .= '

' . t('The file is empty.') . '

'; + } + + $form['files'][$file_name]['data']['#markup'] = $data; + } + } + catch (SearchApiException $e) { + watchdog_exception('search_api_solr', $e, '%type while retrieving config files of Solr server @server: !message in %function (line %line of %file).', array('@server' => $server->name)); + $form['info']['#markup'] = t('An error occured while trying to load the list of files.'); + } + + return $form; +} diff --git a/search_api_solr.api.php b/search_api_solr.api.php index ec4b190c..a64c477b 100644 --- a/search_api_solr.api.php +++ b/search_api_solr.api.php @@ -18,9 +18,9 @@ * is set afterwards. * * @param array $call_args - * An associative array containing all four arguments to the - * Apache_Solr_Service::search() call ("query", "offset", "limit" and - * "params") as references. + * An associative array containing all three arguments to the + * SearchApiSolrConnectionInterface::search() call ("query", "params" and + * "method") as references. * @param SearchApiQueryInterface $query * The SearchApiQueryInterface object representing the executed search query. */ @@ -33,7 +33,7 @@ function hook_search_api_solr_query_alter(array &$call_args, SearchApiQueryInter /** * Change the way the index's field names are mapped to Solr field names. * - * @param $index + * @param SearchApiIndex $index * The index whose field mappings are altered. * @param array $fields * An associative array containing the index field names mapped to their Solr @@ -47,34 +47,50 @@ function hook_search_api_solr_field_mapping_alter(SearchApiIndex $index, array & } /** - * Lets modules alter the search results returned from a Solr search, based on - * the original Solr response. + * Alter Solr documents before they are sent to Solr for indexing. + * + * @param array $documents + * An array of SearchApiSolrDocument objects ready to be indexed, generated + * from $items array. + * @param SearchApiIndex $index + * The search index for which items are being indexed. + * @param array $items + * An array of items being indexed. + */ +function hook_search_api_solr_documents_alter(array &$documents, SearchApiIndex $index, array $items) { + // Adds a "foo" field with value "bar" to all documents. + foreach ($documents as $document) { + $document->setField('foo', 'bar'); + } +} + +/** + * Lets modules alter the search results returned from a Solr search. * * @param array $results * The results array that will be returned for the search. * @param SearchApiQueryInterface $query * The SearchApiQueryInterface object representing the executed search query. - * @param Apache_Solr_Response $response - * The response object returned by Solr. + * @param object $response + * The Solr response object. */ -function hook_search_api_solr_search_results_alter(array &$results, SearchApiQueryInterface $query, Apache_Solr_Response $response) { +function hook_search_api_solr_search_results_alter(array &$results, SearchApiQueryInterface $query, $response) { if (isset($response->facet_counts->facet_fields->custom_field)) { // Do something with $results. } } /** - * Lets modules alter a Solr search request for a multi-index search before - * sending it. + * Lets modules alter a Solr search request for a multi-index search. * - * Apache_Solr_Service::search() is called afterwards with these parameters. - * Please see this method for details on what should be altered where and what - * is set afterwards. + * SearchApiSolrConnectionInterface::search() is called afterwards with these + * parameters. Please see this method for details on what should be altered + * where and what is set afterwards. * * @param array $call_args - * An associative array containing all four arguments to the - * Apache_Solr_Service::search() call ("query", "offset", "limit" and - * "params") as references. + * An associative array containing all three arguments to the + * SearchApiSolrConnectionInterface::search() call ("query", "params" and + * "method") as references. * @param SearchApiMultiQueryInterface $query * The object representing the executed search query. */ @@ -84,46 +100,6 @@ function hook_search_api_solr_multi_query_alter(array &$call_args, SearchApiMult } } -/** - * Define how Search API Solr should index different data types. - * - * It is important to make sure that any types you define are also declared to - * Search API using hook_search_api_data_type_info(). - * - * @return array - * An array containing data type definitions, keyed by their type identifier - * and containing the following keys: - * - prefix: The prefix used by the dynamic field type. - * - always multiValued: (optional) Whether the single/multiple prefix should - * be skipped for this data type. Defaults to FALSE. - * - * @see hook_search_api_solr_dynamic_field_info_alter() - * @see search_api_solr_get_dynamic_field_info() - * @see hook_search_api_data_type_info(). - */ -function hook_search_api_solr_dynamic_field_info() { - return array( - 'example_type' => array( - 'prefix' => 'ex', - // Could be omitted, as FALSE is the default. - 'always multiValued' => FALSE, - ), - ); -} - -/** - * Alter the data type indexing info. - * - * @param array $infos - * The item type info array, keyed by type identifier. - * - * @see hook_search_api_solr_dynamic_field_info() - */ -function hook_search_api_solr_dynamic_field_info_alter(array &$infos) { - // Change the prefix used for example_type. - $info['example_type']['prefix'] = 'ex2'; -} - /** * @} End of "addtogroup hooks". */ diff --git a/search_api_solr.info b/search_api_solr.info index 4659486c..1e6caba6 100644 --- a/search_api_solr.info +++ b/search_api_solr.info @@ -4,15 +4,16 @@ dependencies[] = search_api core = 7.x package = Search -files[] = service.inc -files[] = solr_connection.inc -files[] = solr_field.inc -files[] = includes/solr_httptransport.inc +files[] = includes/document.inc +files[] = includes/service.inc +files[] = includes/solr_connection.inc +files[] = includes/solr_connection.interface.inc +files[] = includes/solr_field.inc files[] = includes/spellcheck.inc -; Information added by drupal.org packaging script on 2013-01-07 -version = "7.x-1.0-rc3" +; Information added by drupal.org packaging script on 2013-09-01 +version = "7.x-1.2" core = "7.x" project = "search_api_solr" -datestamp = "1357517056" +datestamp = "1378026413" diff --git a/search_api_solr.install b/search_api_solr.install index 60270c57..c541a93d 100644 --- a/search_api_solr.install +++ b/search_api_solr.install @@ -1,44 +1,23 @@ array( - 'title' => $t('Solr PHP library'), - 'value' => $t('The library is correctly installed, but out of date'), - 'description' => $t('It is suggested to install the newest version (@version).', array('@version' => 'r60')), - 'severity' => REQUIREMENT_WARNING, - ), - ); - } - return array( - 'search_api_solr' => array( - 'title' => $t('Solr PHP library'), - 'value' => $t('The library was correctly installed'), - 'severity' => REQUIREMENT_OK, - ), - ); - } - else { - return array( - 'search_api_solr' => array( - 'title' => $t('Solr PHP library'), - 'value' => $t('The library was not correctly installed. Please see INSTALL.txt for instructions.'), - 'severity' => REQUIREMENT_ERROR, - ), - ); - } - } - elseif ($phase == 'runtime') { + $ret = array(); + + if ($phase == 'runtime') { $servers = search_api_server_load_multiple(FALSE, array('class' => 'search_api_solr_service', 'enabled' => TRUE)); $count = 0; $unavailable = 0; @@ -71,31 +50,9 @@ function search_api_solr_requirements($phase) { $ret['search_api_solr']['description'] = format_plural($count, 'The Solr server could be reached.', 'All @count Solr servers could be reached.'); $ret['search_api_solr']['severity'] = REQUIREMENT_OK; } - - // Check version of the SolrPhpClient library. - $version = trim(Apache_Solr_Service::SVN_REVISION, '$ :A..Za..z'); - if ($version < 59) { - $ret['search_api_solr_client'] = array( - 'title' => t('Solr PHP library'), - 'value' => t('Version @version', array('@version' => "r$version")), - 'description' => t('The library is correctly installed, but out of date. ' . - 'It is suggested to install the newest version (@version).', - array('@url' => 'http://code.google.com/p/solr-php-client/downloads/list', '@version' => 'r60')), - 'severity' => REQUIREMENT_WARNING, - ); - } - return $ret; } -} -/** - * Implements hook_install(). - * - * We register our autoloader here because our hook_init() won't get called - * until the next bootstrap (it registers the autoloader too.) - */ -function search_api_solr_install() { - spl_autoload_register('_search_api_solr_autoload'); + return $ret; } /** @@ -123,8 +80,6 @@ function search_api_solr_update_dependencies() { } /** - * Implements hook_update_N(). - * * Implements transition from using the index IDs to using machine names. */ function search_api_solr_update_7101() { @@ -152,3 +107,14 @@ function search_api_solr_update_7101() { 'Please stop your Solr servers, replace their schema.xml with the new version and then start them again. ' . 'All data indexed on Solr servers will have to be reindexed.'); } + +/** + * Create the Search API Solr cache table {cache_search_api_solr}. + */ +function search_api_solr_update_7102() { + if (!db_table_exists('cache_search_api_solr')) { + $table = drupal_get_schema_unprocessed('system', 'cache'); + $table['description'] = 'Cache table for the Search API Solr module to store various data related to Solr servers.'; + db_create_table('cache_search_api_solr', $table); + } +} diff --git a/search_api_solr.module b/search_api_solr.module index b75319b0..cfab380e 100644 --- a/search_api_solr.module +++ b/search_api_solr.module @@ -1,76 +1,27 @@ 'Files', + 'description' => 'View Solr configuration files.', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('search_api_solr_solr_config_form', 5), + 'access callback' => 'search_api_access_server_files', + 'access arguments' => array(5), + 'file' => 'search_api_solr.admin.inc', + 'type' => MENU_LOCAL_TASK, + 'weight' => -1, + ); -/** - * Return path to SolrPhpClient library path, or FALSE if not found. - */ -function _search_api_solr_solrphpclient_path() { - static $path = NULL; - - if (!isset($path)) { - $path = FALSE; - // If Libraries API is installed, we first use that to try and find the - // library. Otherwise we manually check a few locations. - $search_dirs = array(); - if (function_exists('libraries_get_path')) { - $dir = libraries_get_path('SolrPhpClient'); - // Confusingly, Libraries API 1.x will return sites/all/libraries/NAME on - // failure, while Libraries API 2.x returns FALSE in that case. - if ($dir) { - $search_dirs[] = $dir; - } - } - else { - // Include libraries + current profile folders in searched directories. - $search_dirs[] = 'sites/all/libraries/SolrPhpClient'; - $search_dirs[] = 'profiles/' . drupal_get_profile() . '/libraries/SolrPhpClient'; - } - $search_dirs[] = drupal_get_path('module', 'search_api_solr') . '/SolrPhpClient'; - foreach ($search_dirs as $dir) { - $dir = DRUPAL_ROOT . '/' . $dir; - if (is_dir($dir)) { - $path = $dir; - break; - } - } - } - - if ($path == FALSE) { - throw new Exception('SolrPhpClient library not found! Please follow the instructions in search_api_solr/INSTALL.txt for installing the Solr search module.'); - } - - return $path; -} - -/** - * Autoloader for the SolrPhpClient classes. - */ -function _search_api_solr_autoload($name) { - static $lookup_cache = array(); - - if (isset($lookup_cache[$name])) { - return $lookup_cache[$name]; - } - elseif (substr($name, 0, 11) == 'Apache_Solr') { - $path = _search_api_solr_solrphpclient_path(); - if (file_exists($file_path = $path . '/' . str_replace('_', '/', $name) . '.php')) { - require_once $file_path; - $lookup_cache[$name] = TRUE; - return TRUE; - } - } - $lookup_cache[$name] = FALSE; - return FALSE; + return $items; } /** @@ -135,7 +86,7 @@ function search_api_solr_cron() { $conditions = array('class' => 'search_api_solr_service', 'enabled' => TRUE); foreach (search_api_server_load_multiple(FALSE, $conditions) as $server) { try { - $server->getSolrConnection()->optimize(FALSE, FALSE); + $server->getSolrConnection()->optimize(FALSE); } catch(Exception $e) { watchdog_exception('search_api_solr', $e, '%type while optimizing Solr server @server: !message in %function (line %line of %file).', array('@server' => $server->name)); @@ -145,79 +96,119 @@ function search_api_solr_cron() { } /** - * Returns either all dynamic field types, or a specific one. - * - * @param $type - * If specified, the type whose definition should be returned. - * - * @return array - * If $type was not given, an array containing all custom dynamic fields, in - * the format specified by hook_search_api_solr_dynamic_field_info(). - * Otherwise, the definition for the given type, or NULL if it is unknown. - * - * @see hook_search_api_solr_dynamic_field_info(). + * Implements hook_flush_caches(). */ -function search_api_solr_get_dynamic_field_info($type = NULL) { - $types = &drupal_static(__FUNCTION__); - if (!isset($types)) { - $types = module_invoke_all('search_api_solr_dynamic_field_info'); - $types = $types ? $types : array(); - drupal_alter('search_api_solr_dynamic_field_info', $types); +function search_api_solr_flush_caches() { + return array('cache_search_api_solr'); +} + + +/** + * Implements hook_search_api_server_update(). + */ +function search_api_solr_search_api_server_update(SearchApiServer $server) { + if ($server->class === 'search_api_solr_service') { + $server->getSolrConnection()->clearCache(); } - if (isset($type)) { - return isset($types[$type]) ? $types[$type] : NULL; - } - return $types; } /** - * Implements hook_search_api_solr_dynamic_field_info(). + * Retrieves a list of all config files of a server. + * + * @param SearchApiServer $server + * The Solr server whose files should be retrieved. + * @param string $dir_name + * (optional) The directory that should be searched for files. Defaults to the + * root config directory. + * + * @return array + * An associative array of all config files in the given directory. The keys + * are the file names, values are arrays with information about the file. The + * files are returned in alphabetical order and breadth-first. + * + * @throws SearchApiException + * If a problem occurred while retrieving the files. */ -function search_api_solr_search_api_solr_dynamic_field_info() { - return array( - 'text' => array( - 'prefix' => 'tm', - 'always multiValued' => TRUE, - ), - 'tokens' => array( - 'prefix' => 'tm', - 'always multiValued' => TRUE, - ), - 'string' => array( - 'prefix' => 's', - 'always multiValued' => FALSE, - ), - 'integer' => array( - 'prefix' => 'i', - 'always multiValued' => FALSE, - ), - 'decimal' => array( - 'prefix' => 'f', - 'always multiValued' => FALSE, - ), - 'date' => array( - 'prefix' => 'd', - 'always multiValued' => FALSE, - ), - 'duration' => array( - 'i', - 'always multiValued' => FALSE, - ), - 'boolean' => array( - 'b', - 'always multiValued' => FALSE, - ), - 'uri' => array( - 's', - 'always multiValued' => FALSE, - ), - 'location' => array( - 'loc', - 'always multiValued' => FALSE, - ), - 'geohash' => array( - 'geohash', - 'always multiValued' => FALSE, - ), - ); +function search_api_solr_server_get_files(SearchApiServer $server, $dir_name = NULL) { + $response = $server->getFile($dir_name); + + // Search for directories and recursively merge directory files. + $files_data = json_decode($response->data, TRUE); + $files_list = $files_data['files']; + $result = array('' => array()); + + foreach ($files_list as $file_name => $file_info) { + if (empty($file_info['directory'])) { + $result[''][$file_name] = $file_info; + } + else { + $result[$file_name] = search_api_solr_server_get_files($server, $file_name); + } + } + + ksort($result); + ksort($result['']); + return array_reduce($result, 'array_merge', array()); +} + +/** + * Access callback for a server's "Files" tab. + * + * Grants access if the user has the "administer search_api" permission and the + * server is a Solr server. + * + * @param SearchApiServer $server + * The server for which access should be tested. + * + * @return bool + * TRUE if access should be granted, FALSE otherwise. + */ +function search_api_access_server_files(SearchApiServer $server) { + if (!user_access('administer search_api')) { + return FALSE; + } + $service_info = search_api_get_service_info($server->class); + $service_class = $service_info['class']; + + if (empty($service_class) || !class_exists($service_class)) { + // Service class not found. + return FALSE; + } + if ($service_class == 'SearchApiSolrService' || in_array('SearchApiSolrService', class_parents($service_class))) { + // It's an SearchApiSolrService based connection class. + return TRUE; + } + + return FALSE; +} + +/** + * Switches a server to use clean identifiers. + * + * Used as a submit callback in SearchApiSolrService::configurationForm(). + */ +function _search_api_solr_switch_to_clean_ids(array $form, array &$form_state) { + $server = $form_state['server']; + $server->options['clean_ids'] = TRUE; + $server->save(); + drupal_set_message(t('The Solr server was successfully switched to use clean field identifiers.')); + + $count = 0; + $conditions['server'] = $server->machine_name; + $conditions['enabled'] = 1; + foreach (search_api_index_load_multiple(FALSE, $conditions) as $index) { + if (!empty($index->options['fields'])) { + foreach ($index->options['fields'] as $key => $field) { + if (strpos($key, ':') !== FALSE) { + $index->reindex(); + ++$count; + break; + } + } + } + } + if ($count) { + $msg = format_plural($count, '1 index was scheduled for re-indexing.', '@count indexes were scheduled for re-indexing.'); + drupal_set_message($msg); + } } diff --git a/solr-conf/1.4/elevate.xml b/solr-conf/1.4/elevate.xml new file mode 100644 index 00000000..71ea0006 --- /dev/null +++ b/solr-conf/1.4/elevate.xml @@ -0,0 +1,31 @@ + + + + + + + + + + diff --git a/solr-conf/1.4/mapping-ISOLatin1Accent.txt b/solr-conf/1.4/mapping-ISOLatin1Accent.txt new file mode 100644 index 00000000..b92d03c5 --- /dev/null +++ b/solr-conf/1.4/mapping-ISOLatin1Accent.txt @@ -0,0 +1,14 @@ +# This file contains character mappings for the default fulltext field type. +# The source characters (on the left) will be replaced by the respective target +# characters before any other processing takes place. +# Lines starting with a pound character # are ignored. +# +# For sensible defaults, use the mapping-ISOLatin1Accent.txt file distributed +# with the example application of your Solr version. +# +# Examples: +# "À" => "A" +# "\u00c4" => "A" +# "\u00c4" => "\u0041" +# "æ" => "ae" +# "\n" => " " diff --git a/solr-conf/1.4/schema.xml b/solr-conf/1.4/schema.xml index 543d2766..3c7a45ae 100644 --- a/solr-conf/1.4/schema.xml +++ b/solr-conf/1.4/schema.xml @@ -10,7 +10,7 @@ http://wiki.apache.org/solr/SchemaXml --> - + - - - - - + + + + + - - - - - + + + + diff --git a/solr-conf/1.4/schema_extra_fields.xml b/solr-conf/1.4/schema_extra_fields.xml new file mode 100644 index 00000000..9ecd5f4f --- /dev/null +++ b/solr-conf/1.4/schema_extra_fields.xml @@ -0,0 +1,23 @@ + + + + diff --git a/solr-conf/1.4/schema_extra_types.xml b/solr-conf/1.4/schema_extra_types.xml new file mode 100644 index 00000000..e82072e2 --- /dev/null +++ b/solr-conf/1.4/schema_extra_types.xml @@ -0,0 +1,30 @@ + + + + diff --git a/solr-conf/1.4/solrconfig.xml b/solr-conf/1.4/solrconfig.xml index 246be0e0..5798444a 100644 --- a/solr-conf/1.4/solrconfig.xml +++ b/solr-conf/1.4/solrconfig.xml @@ -20,7 +20,7 @@ For more details about configurations options that may appear in this file, see http://wiki.apache.org/solr/SolrConfigXml. --> - + - 10000 - 120000 + ${solr.autoCommit.MaxDocs:10000} + ${solr.autoCommit.MaxTime:120000} - ${pinkPony.timeAllowed:-1} + ${solr.pinkPony.timeAllowed:-1} *:* @@ -876,7 +876,15 @@ 20 false - ${mlt.timeAllowed:2000} + ${solr.mlt.timeAllowed:2000} + + + + + + + explicit + true @@ -1070,15 +1078,15 @@ --> - ${enable.master:false} + ${solr.replication.master:false} commit startup - ${confFiles} + ${solr.replication.confFiles:schema.xml,mapping-ISOLatin1Accent.txt,protwords.txt,stopwords.txt,synonyms.txt,elevate.xml} - ${enable.slave:false} - ${masterCoreUrl}/replication - ${pollTime:00:00:60} + ${solr.replication.slave:false} + ${solr.replication.masterUrl:http://localhost:8983/solr}/replication + ${solr.replication.pollInterval:00:00:60} @@ -1125,73 +1133,6 @@ --> - - - - textSpell - - - - - - default - name - spellchecker - - - - - - - - - - - - - + + + + + + + + + textSpell + + + + default + spell + spellchecker + true + + + + + diff --git a/solr-conf/1.4/solrconfig_extra.xml b/solr-conf/1.4/solrconfig_extra.xml new file mode 100644 index 00000000..c5bc3acf --- /dev/null +++ b/solr-conf/1.4/solrconfig_extra.xml @@ -0,0 +1,80 @@ + + + +textSpell + + + + + + default + spell + spellchecker + true + + + + + + + + + + + + + + + diff --git a/solr-conf/1.4/solrcore.properties b/solr-conf/1.4/solrcore.properties index 476f8ddb..f5ede05e 100644 --- a/solr-conf/1.4/solrcore.properties +++ b/solr-conf/1.4/solrcore.properties @@ -1,8 +1,10 @@ -#solrcore.properties for this specific core -enable.master=false -enable.slave=false -pollTime=00:00:60 -masterCoreUrl=http://localhost:8983/solr -confFiles=schema.xml,mapping-ISOLatin1Accent.txt,protwords.txt,stopwords.txt,synonyms.txt,elevate.xml -mlt.timeAllowed=2000 -pinkPony.timeAllowed=-1 +# Defines Solr properties for this specific core. +solr.replication.master=false +solr.replication.slave=false +solr.replication.pollInterval=00:00:60 +solr.replication.masterUrl=http://localhost:8983/solr +solr.replication.confFiles=schema.xml,mapping-ISOLatin1Accent.txt,protwords.txt,stopwords.txt,synonyms.txt,elevate.xml +solr.mlt.timeAllowed=2000 +solr.pinkPony.timeAllowed=-1 +solr.autoCommit.MaxDocs=10000 +solr.autoCommit.MaxTime=120000 diff --git a/solr-conf/1.4/stopwords.txt b/solr-conf/1.4/stopwords.txt new file mode 100644 index 00000000..045f6d10 --- /dev/null +++ b/solr-conf/1.4/stopwords.txt @@ -0,0 +1,4 @@ +# Contains words which shouldn't be indexed for fulltext fields, e.g., because +# they're to common. For documentation of the format, see +# http://wiki.apache.org/solr/AnalyzersTokenizersTokenFilters#solr.StopFilterFactory +# (Lines starting with a pound character # are ignored.) diff --git a/solr-conf/1.4/synonyms.txt b/solr-conf/1.4/synonyms.txt new file mode 100644 index 00000000..7d22eea6 --- /dev/null +++ b/solr-conf/1.4/synonyms.txt @@ -0,0 +1,3 @@ +# Contains synonyms to use for your index. For the format used, see +# http://wiki.apache.org/solr/AnalyzersTokenizersTokenFilters#solr.SynonymFilterFactory +# (Lines starting with a pound character # are ignored.) diff --git a/solr-conf/3.x/elevate.xml b/solr-conf/3.x/elevate.xml new file mode 100644 index 00000000..71ea0006 --- /dev/null +++ b/solr-conf/3.x/elevate.xml @@ -0,0 +1,31 @@ + + + + + + + + + + diff --git a/solr-conf/3.x/mapping-ISOLatin1Accent.txt b/solr-conf/3.x/mapping-ISOLatin1Accent.txt new file mode 100644 index 00000000..b92d03c5 --- /dev/null +++ b/solr-conf/3.x/mapping-ISOLatin1Accent.txt @@ -0,0 +1,14 @@ +# This file contains character mappings for the default fulltext field type. +# The source characters (on the left) will be replaced by the respective target +# characters before any other processing takes place. +# Lines starting with a pound character # are ignored. +# +# For sensible defaults, use the mapping-ISOLatin1Accent.txt file distributed +# with the example application of your Solr version. +# +# Examples: +# "À" => "A" +# "\u00c4" => "A" +# "\u00c4" => "\u0041" +# "æ" => "ae" +# "\n" => " " diff --git a/solr-conf/3.x/schema.xml b/solr-conf/3.x/schema.xml index dff885d1..6953ccba 100644 --- a/solr-conf/3.x/schema.xml +++ b/solr-conf/3.x/schema.xml @@ -10,7 +10,7 @@ http://wiki.apache.org/solr/SchemaXml --> - + - - - - - - + + + + - - - - - + + + + diff --git a/solr-conf/3.x/schema_extra_fields.xml b/solr-conf/3.x/schema_extra_fields.xml new file mode 100644 index 00000000..9ecd5f4f --- /dev/null +++ b/solr-conf/3.x/schema_extra_fields.xml @@ -0,0 +1,23 @@ + + + + diff --git a/solr-conf/3.x/schema_extra_types.xml b/solr-conf/3.x/schema_extra_types.xml new file mode 100644 index 00000000..e82072e2 --- /dev/null +++ b/solr-conf/3.x/schema_extra_types.xml @@ -0,0 +1,30 @@ + + + + diff --git a/solr-conf/3.x/solrconfig.xml b/solr-conf/3.x/solrconfig.xml index 841963d6..fc0ca526 100644 --- a/solr-conf/3.x/solrconfig.xml +++ b/solr-conf/3.x/solrconfig.xml @@ -20,7 +20,7 @@ For more details about configurations options that may appear in this file, see http://wiki.apache.org/solr/SolrConfigXml. --> - + - ${luceneVersion:LUCENE_35} + ${solr.luceneMatchVersion:LUCENE_35} - 10000 - 120000 + ${solr.autoCommit.MaxDocs:10000} + ${solr.autoCommit.MaxTime:120000} - ${pinkPony.timeAllowed:-1} + ${solr.pinkPony.timeAllowed:-1} *:* @@ -884,7 +884,15 @@ 20 false - ${mlt.timeAllowed:2000} + ${solr.mlt.timeAllowed:2000} + + + + + + + explicit + true @@ -1078,15 +1086,15 @@ --> - ${enable.master:false} + ${solr.replication.master:false} commit startup - ${confFiles} + ${solr.replication.confFiles:schema.xml,mapping-ISOLatin1Accent.txt,protwords.txt,stopwords.txt,synonyms.txt,elevate.xml} - ${enable.slave:false} - ${masterCoreUrl}/replication - ${pollTime:00:00:60} + ${solr.replication.slave:false} + ${solr.replication.masterUrl:http://localhost:8983/solr}/replication + ${solr.replication.pollInterval:00:00:60} @@ -1133,73 +1141,6 @@ --> - - - - textSpell - - - - - - default - name - spellchecker - - - - - - - - - - - - - + + + + + + textSpell + + + + default + spell + spellchecker + true + + + + + diff --git a/solr-conf/3.x/solrconfig_extra.xml b/solr-conf/3.x/solrconfig_extra.xml new file mode 100644 index 00000000..c5bc3acf --- /dev/null +++ b/solr-conf/3.x/solrconfig_extra.xml @@ -0,0 +1,80 @@ + + + +textSpell + + + + + + default + spell + spellchecker + true + + + + + + + + + + + + + + + diff --git a/solr-conf/3.x/solrcore.properties b/solr-conf/3.x/solrcore.properties index 0f3933d2..54a33c95 100644 --- a/solr-conf/3.x/solrcore.properties +++ b/solr-conf/3.x/solrcore.properties @@ -1,10 +1,12 @@ -#solrcore.properties for this specific core -enable.master=false -enable.slave=false -pollTime=00:00:60 -masterCoreUrl=http://localhost:8983/solr -confFiles=schema.xml,mapping-ISOLatin1Accent.txt,protwords.txt,stopwords.txt,synonyms.txt,elevate.xml -mlt.timeAllowed=2000 -# You should not set your luceneVersion to anything lower then your Solr Version -luceneVersion=LUCENE_35 -pinkPony.timeAllowed=-1 +# Defines Solr properties for this specific core. +solr.replication.master=false +solr.replication.slave=false +solr.replication.pollInterval=00:00:60 +solr.replication.masterUrl=http://localhost:8983/solr +solr.replication.confFiles=schema.xml,mapping-ISOLatin1Accent.txt,protwords.txt,stopwords.txt,synonyms.txt,elevate.xml +solr.mlt.timeAllowed=2000 +# You should not set your luceneVersion to anything lower then your Solr Version. +solr.luceneMatchVersion=LUCENE_35 +solr.pinkPony.timeAllowed=-1 +solr.autoCommit.MaxDocs=10000 +solr.autoCommit.MaxTime=120000 diff --git a/solr-conf/3.x/stopwords.txt b/solr-conf/3.x/stopwords.txt new file mode 100644 index 00000000..045f6d10 --- /dev/null +++ b/solr-conf/3.x/stopwords.txt @@ -0,0 +1,4 @@ +# Contains words which shouldn't be indexed for fulltext fields, e.g., because +# they're to common. For documentation of the format, see +# http://wiki.apache.org/solr/AnalyzersTokenizersTokenFilters#solr.StopFilterFactory +# (Lines starting with a pound character # are ignored.) diff --git a/solr-conf/3.x/synonyms.txt b/solr-conf/3.x/synonyms.txt new file mode 100644 index 00000000..7d22eea6 --- /dev/null +++ b/solr-conf/3.x/synonyms.txt @@ -0,0 +1,3 @@ +# Contains synonyms to use for your index. For the format used, see +# http://wiki.apache.org/solr/AnalyzersTokenizersTokenFilters#solr.SynonymFilterFactory +# (Lines starting with a pound character # are ignored.) diff --git a/solr-conf/4.x/elevate.xml b/solr-conf/4.x/elevate.xml new file mode 100644 index 00000000..71ea0006 --- /dev/null +++ b/solr-conf/4.x/elevate.xml @@ -0,0 +1,31 @@ + + + + + + + + + + diff --git a/solr-conf/4.x/mapping-ISOLatin1Accent.txt b/solr-conf/4.x/mapping-ISOLatin1Accent.txt new file mode 100644 index 00000000..b92d03c5 --- /dev/null +++ b/solr-conf/4.x/mapping-ISOLatin1Accent.txt @@ -0,0 +1,14 @@ +# This file contains character mappings for the default fulltext field type. +# The source characters (on the left) will be replaced by the respective target +# characters before any other processing takes place. +# Lines starting with a pound character # are ignored. +# +# For sensible defaults, use the mapping-ISOLatin1Accent.txt file distributed +# with the example application of your Solr version. +# +# Examples: +# "À" => "A" +# "\u00c4" => "A" +# "\u00c4" => "\u0041" +# "æ" => "ae" +# "\n" => " " diff --git a/solr-conf/4.x/protwords.txt b/solr-conf/4.x/protwords.txt new file mode 100644 index 00000000..cda85814 --- /dev/null +++ b/solr-conf/4.x/protwords.txt @@ -0,0 +1,7 @@ +#----------------------------------------------------------------------- +# This file blocks words from being operated on by the stemmer and word delimiter. +& +< +> +' +" diff --git a/solr-conf/4.x/schema.xml b/solr-conf/4.x/schema.xml new file mode 100644 index 00000000..6e8e7961 --- /dev/null +++ b/solr-conf/4.x/schema.xml @@ -0,0 +1,547 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id + + + content + + + + + diff --git a/solr-conf/4.x/schema_extra_fields.xml b/solr-conf/4.x/schema_extra_fields.xml new file mode 100644 index 00000000..9ecd5f4f --- /dev/null +++ b/solr-conf/4.x/schema_extra_fields.xml @@ -0,0 +1,23 @@ + + + + diff --git a/solr-conf/4.x/schema_extra_types.xml b/solr-conf/4.x/schema_extra_types.xml new file mode 100644 index 00000000..e82072e2 --- /dev/null +++ b/solr-conf/4.x/schema_extra_types.xml @@ -0,0 +1,30 @@ + + + + diff --git a/solr-conf/4.x/solrconfig.xml b/solr-conf/4.x/solrconfig.xml new file mode 100644 index 00000000..d408253e --- /dev/null +++ b/solr-conf/4.x/solrconfig.xml @@ -0,0 +1,1603 @@ + + + + + + + + + ${solr.abortOnConfigurationError:true} + + + ${solr.luceneMatchVersion:LUCENE_40} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + + 4 + + 32 + + + + 2147483647 + 100000 + 1000 + + + + + + + + + single + + + + + false + 32 + 10 + + + false + + + true + + + + + 1 + + 0 + + + + + + false + + + + + + + + + + + + + + + + ${solr.autoCommit.MaxDocs:10000} + ${solr.autoCommit.MaxTime:120000} + + + + + + + + + + + + + + + + + 1024 + + + + + + + + + + + + + + + + + + + + + + true + + + + + + 20 + + + 200 + + + + + + + + + + + + solr rocks010 + + + + + + false + + + 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + edismax + explicit + true + 0.01 + + ${solr.pinkPony.timeAllowed:-1} + *:* + + + false + + true + false + + 1 + + + spellcheck + + + + + + + 1 + 1 + 3 + 15 + 20 + false + + ${solr.mlt.timeAllowed:2000} + + + + + + + explicit + true + + + + + + + + + + + + + + + + + + + + + + text + true + ignored_ + + + true + links + ignored_ + + + + + + + + + + + + + + + + + + + + + + + + pinkPony + solrpingquery + + + all + + + + + + + explicit + true + + + + + + + ${solr.replication.master:false} + commit + startup + ${solr.replication.confFiles:schema.xml,mapping-ISOLatin1Accent.txt,protwords.txt,stopwords.txt,synonyms.txt,elevate.xml} + + + ${solr.replication.slave:false} + ${solr.replication.masterUrl:http://localhost:8983/solr}/replication + ${solr.replication.pollInterval:00:00:60} + + + + + + + + + false + false + 1 + + + spellcheck + + + + + + + + + + true + + + tvComponent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + terms + + + + + + + + string + elevate.xml + + + + + + explicit + + + elevator + + + + + + + + + + + 100 + + + + + + + + 70 + + 0.5 + + [-\w ,/\n\"']{20,200} + + + + + + + ]]> + ]]> + + + + + + + + + + + + + + + + + + + + + ,, + ,, + ,, + ,, + ,]]> + ]]> + + + + + + 10 + .,!? + + + + + + + WORD + + + en + US + + + + + + + + + + + + + + + + + + + text/plain; charset=UTF-8 + + + + + + + + + + 5 + + + + + + + + + + + + + *:* + + + + + + + + + + + textSpell + + + + default + spell + spellchecker + true + + + + + + diff --git a/solr-conf/4.x/solrconfig_extra.xml b/solr-conf/4.x/solrconfig_extra.xml new file mode 100644 index 00000000..c5bc3acf --- /dev/null +++ b/solr-conf/4.x/solrconfig_extra.xml @@ -0,0 +1,80 @@ + + + +textSpell + + + + + + default + spell + spellchecker + true + + + + + + + + + + + + + + + diff --git a/solr-conf/4.x/solrcore.properties b/solr-conf/4.x/solrcore.properties new file mode 100644 index 00000000..a2eb167e --- /dev/null +++ b/solr-conf/4.x/solrcore.properties @@ -0,0 +1,12 @@ +# Defines Solr properties for this specific core. +solr.replication.master=false +solr.replication.slave=false +solr.replication.pollInterval=00:00:60 +solr.replication.masterUrl=http://localhost:8983/solr +solr.replication.confFiles=schema.xml,mapping-ISOLatin1Accent.txt,protwords.txt,stopwords.txt,synonyms.txt,elevate.xml +solr.mlt.timeAllowed=2000 +# You should not set your luceneVersion to anything lower then your Solr Version. +solr.luceneMatchVersion=LUCENE_40 +solr.pinkPony.timeAllowed=-1 +solr.autoCommit.MaxDocs=10000 +solr.autoCommit.MaxTime=120000 diff --git a/solr-conf/4.x/stopwords.txt b/solr-conf/4.x/stopwords.txt new file mode 100644 index 00000000..d7f243e4 --- /dev/null +++ b/solr-conf/4.x/stopwords.txt @@ -0,0 +1,4 @@ +# Contains words which shouldn't be indexed for fulltext fields, e.g., because +# they're too common. For documentation of the format, see +# http://wiki.apache.org/solr/AnalyzersTokenizersTokenFilters#solr.StopFilterFactory +# (Lines starting with a pound character # are ignored.) diff --git a/solr-conf/4.x/synonyms.txt b/solr-conf/4.x/synonyms.txt new file mode 100644 index 00000000..7d22eea6 --- /dev/null +++ b/solr-conf/4.x/synonyms.txt @@ -0,0 +1,3 @@ +# Contains synonyms to use for your index. For the format used, see +# http://wiki.apache.org/solr/AnalyzersTokenizersTokenFilters#solr.SynonymFilterFactory +# (Lines starting with a pound character # are ignored.) diff --git a/solr_connection.inc b/solr_connection.inc deleted file mode 100644 index 770a7b6e..00000000 --- a/solr_connection.inc +++ /dev/null @@ -1,259 +0,0 @@ - 'localhost', - 'port' => 8983, - 'path' => '', - 'http_user' => NULL, - 'http_pass' => NULL, - 'default_field'=>'id', - ); - parent::__construct($options['host'], $options['port'], $options['path']); - if ($options['http_user'] && $options['http_pass']) { - $this->http_auth = 'Basic ' . base64_encode($options['http_user'] . ':' . $options['http_pass']); - } - // Since /ping otherwise complains about missing default field. - $this->_pingUrl .= '?q=' . $options['default_field'] . ':1'; - - // As of July 2011, the newest release is r60, with Service.php having - // revision 59. Revision 40 is just anything between 22 (old) and that. - $this->newClient = trim(parent::SVN_REVISION, '$ :A..Za..z') > 40; - if ($this->newClient) { - $this->_httpTransport = new SearchApiSolrHttpTransport($this->http_auth); - } - } - - /** - * Central method for making a get operation against this Solr Server. - * - * @see Apache_Solr_Service::_sendRawGet() - */ - protected function _sendRawGet($url, $timeout = FALSE) { - // Little "hack" to allow filter-only queries - // Since "*:*" doesn't work with the dismax query handler, we mustn't set - // "q", to let "q.alt" kick in. However, Apache_Solr_Service::search() will - // always add "q", even if it is empty. Therefore, we delete empty "q" - // parameters here. - $url = preg_replace('/([?&])q=(&|$)/', '$1', $url); - - if ($this->newClient) { - return parent::_sendRawGet($url, $timeout); - } - - list($data, $headers) = $this->_makeHttpRequest($url, 'GET', array(), '', $timeout); - $response = new Apache_Solr_Response($data, $headers, $this->_createDocuments, $this->_collapseSingleValueArrays); - $code = (int) $response->getHttpStatus(); - if ($code != 200) { - $message = $response->getHttpStatusMessage(); - if ($code >= 400 && $code != 403 && $code != 404) { - // Add details, like Solr's exception message. - $message .= $response->getRawResponse(); - } - throw new Exception('"' . $code . '" Status: ' . $message); - } - return $response; - } - - /** - * Central method for making a post operation against this Solr Server. - * - * @see Apache_Solr_Service::_sendRawPost() - */ - protected function _sendRawPost($url, $rawPost, $timeout = FALSE, $contentType = 'text/xml; charset=UTF-8') { - if ($this->newClient) { - return parent::_sendRawPost($url, $rawPost, $timeout, $contentType); - } - - $request_headers = array('Content-Type' => $contentType); - list($data, $headers) = $this->_makeHttpRequest($url, 'POST', $request_headers, $rawPost, $timeout); - $response = new Apache_Solr_Response($data, $headers, $this->_createDocuments, $this->_collapseSingleValueArrays); - $code = (int) $response->getHttpStatus(); - if ($code != 200) { - $message = $response->getHttpStatusMessage(); - if ($code >= 400 && $code != 403 && $code != 404) { - // Add details, like Solr's exception message. - $message .= $response->getRawResponse(); - } - throw new Exception('"' . $code . '" Status: ' . $message); - } - return $response; - } - - - /** - * Call the /admin/ping servlet, to test the connection to the server. - * - * @param $timeout - * maximum time to wait for ping in seconds, -1 for unlimited (default 2). - * @return - * (float) seconds taken to ping the server, FALSE if timeout occurs. - */ - public function ping($timeout = 2) { - if ($this->newClient) { - return parent::ping($timeout); - } - $start = microtime(TRUE); - - if ($timeout <= 0.0) { - $timeout = -1; - } - // Attempt a HEAD request to the solr ping url. - list($data, $headers) = $this->_makeHttpRequest($this->_pingUrl, 'HEAD', array(), NULL, $timeout); - $response = new Apache_Solr_Response($data, $headers); - - if ($response->getHttpStatus() == 200) { - // Add 0.1 ms to the ping time so we never return 0.0. - return microtime(TRUE) - $start + 0.0001; - } - else { - return FALSE; - } - } - - /** - * Helper method for making an HTTP request, without using stupid stuff like - * file_get_contents(). - */ - protected function _makeHttpRequest($url, $method = 'GET', $headers = array(), $content = '', $timeout = FALSE) { - $options = array( - 'headers' => $headers, - 'method' => $method, - 'data' => $content, - ); - - if ($this->http_auth) { - $options['headers']['Authorization'] = $this->http_auth; - } - if ($timeout) { - $options['timeout'] = $timeout; - } - - $result = drupal_http_request($url, $options); - - if (!isset($result->code) || $result->code < 0) { - $result->code = 0; - $result->status_message = 'Request failed'; - $result->protocol = 'HTTP/1.0'; - } - // Additional information may be in the error property. - if (isset($result->error)) { - $result->status_message .= ': ' . check_plain($result->error); - } - - if (!isset($result->data)) { - $result->data = ''; - } - // The headers have to be reformatted for the response class. - $headers[] = "{$result->protocol} {$result->code} {$result->status_message}"; - if (isset($result->headers)) { - foreach ($result->headers as $name => $value) { - $headers[] = "$name: $value"; - } - } - return array($result->data, $headers); - } - - /** - * Convenience function for escaping a field name. - * - * Since field names can only contain one special character, ":", there is no - * need to use the complete escape() method. - * - * @param string $value - * The field name to escape. - * - * @return string - * An escaped string suitable for passing to Solr. - */ - static public function escapeFieldName($value) { - $value = str_replace(':', '\:', $value); - return $value; - } - - /** - * Convenience function for creating phrase syntax from a value. - * - * @param string $value - * The string to convert into a Solr phrase value. - * - * @return string - * A quoted string suitable for passing to Solr. - */ - static public function phrase($value) { - $value = str_replace("\\", "\\\\", $value); - $value = str_replace('"', '\"', $value); - return '"' . $value . '"'; - } - - /** - * Get metadata about the Lucene index. - * - * @param int $num_terms - * Number of 'top terms' to return. - * - * @return Apache_Solr_Response - * A response object containing schema information. - */ - public function getLuke($num_terms = 0) { - if (!isset($this->luke[$num_terms])) { - $url = $this->_constructUrl(self::LUKE_SERVLET, array('numTerms' => "$num_terms", 'wt' => self::SOLR_WRITER)); - $this->luke[$num_terms] = $this->_sendRawGet($url); - } - return $this->luke[$num_terms]; - } - - /** - * Get metadata about fields in the Lucene index. - * - * @return array - * An array of objects, keyed by field name, describing fields on the index. - * - * @see SearchApiSolrConnection::getLuke() - * @see http://wiki.apache.org/solr/LukeRequestHandler - */ - public function getFields() { - return (array) $this->getLuke()->fields; - } - -}