當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Apache_Solr_Response類代碼示例

本文整理匯總了PHP中Apache_Solr_Response的典型用法代碼示例。如果您正苦於以下問題:PHP Apache_Solr_Response類的具體用法?PHP Apache_Solr_Response怎麽用?PHP Apache_Solr_Response使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Apache_Solr_Response類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _sendRawPost

 /**
  * Central method for making a post operation against this Solr Server
  *
  * @see Drupal_Apache_Solr_Service::_sendRawGet()
  */
 protected function _sendRawPost($url, $rawPost, $timeout = FALSE, $contentType = 'text/xml; charset=UTF-8')
 {
     $id = $this->add_request_id($url);
     list($cookie, $nonce) = acquia_search_auth_cookie($url, $rawPost);
     $request_headers = array('Content-Type' => $contentType, 'Cookie' => $cookie, 'User-Agent' => 'acquia_search/' . ACQUIA_SEARCH_VERSION);
     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() . "\n request ID: {$id} \n";
         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;
 }
開發者ID:rtanglao,項目名稱:ad6-svn,代碼行數:23,代碼來源:Acquia_Search_Service.php

示例2: _sendRawPost

 /**
  * Central method for making a post operation against this Solr Server
  *
  * @see Drupal_Apache_Solr_Service::_sendRawGet()
  */
 protected function _sendRawPost($url, $rawPost, $timeout = FALSE, $contentType = 'text/xml; charset=UTF-8')
 {
     if (variable_get('apachesolr_read_only', 0)) {
         throw new Exception('Operating in read-only mode; updates are disabled.');
     }
     $id = $this->add_request_id($url);
     list($cookie, $nonce) = acquia_search_auth_cookie($url, $rawPost);
     if (empty($cookie)) {
         throw new Exception('Invalid authentication string - subscription keys expired or missing.');
     }
     $request_headers = array('Content-Type' => $contentType, 'Cookie' => $cookie, 'User-Agent' => 'acquia_search/' . ACQUIA_SEARCH_VERSION);
     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() . "\n request ID: {$id} \n";
         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;
 }
開發者ID:kdb,項目名稱:kbhlydavis,代碼行數:29,代碼來源:Acquia_Search_Service.php

示例3: _sendRawPost

 /**
  * Central method for making a post operation against this Solr Server
  *
  * @see Drupal_Apache_Solr_Service::_sendRawGet()
  */
 protected function _sendRawPost($url, $rawPost, $timeout = FALSE, $contentType = 'text/xml; charset=UTF-8')
 {
     $this->add_request_id($url);
     list($cookie, $nonce) = acquia_search_auth_cookie($url, $rawPost);
     $request_headers = array('Content-Type' => $contentType, 'Cookie' => $cookie);
     list($data, $headers) = $this->_makeHttpRequest($url, 'POST', $request_headers, $rawPost, $timeout);
     $response = new Apache_Solr_Response($data, $headers, $this->_createDocuments, $this->_collapseSingleValueArrays);
     if ($response->getHttpStatus() != 200) {
         throw new Exception('"' . $response->getHttpStatus() . '" Status: ' . $response->getHttpStatusMessage() . "\n<br />request ID: {$id} <br />" . $url, $response->getHttpStatus());
     }
     return $response;
 }
開發者ID:rtanglao,項目名稱:acquia-drupal-6,代碼行數:17,代碼來源:Acquia_Search_Service.php

示例4: _sendRawPost

 /**
  * 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')
 {
     stream_context_set_option($this->_postContext, array('http' => array('method' => 'POST', 'header' => "Content-Type: {$contentType}", 'content' => $rawPost, 'timeout' => $this->_defaultTimeout)));
     // 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 = (double) $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;
     $response = new Apache_Solr_Response(@file_get_contents($url, false, $this->_postContext), $http_response_header, $this->_createDocuments, $this->_collapseSingleValueArrays);
     if ($response->getHttpStatus() != 200) {
         throw new Apache_Solr_HttpTransportException($response);
     }
     return $response;
 }
開發者ID:rande,項目名稱:sfSolrPlugin,代碼行數:31,代碼來源:Service.php

示例5: _sendRawPost

 /**
  * Central method for making a post operation against this Solr Server
  *
  * @param string $url
  * @param string $rawPost
  * @param float $timeout Read timeout in seconds
  * @param string $contentType
  * @return Apache_Solr_Response
  *
  * @throws Exception If a non 200 response status is returned
  */
 protected function _sendRawPost($url, $rawPost, $timeout = FALSE, $contentType = 'text/xml; charset=UTF-8')
 {
     list($output, $info) = $this->_curlGetContents($url, $rawPost, $timeout, $contentType);
     $response = new Apache_Solr_Response($output, $info, $this->_createDocuments, $this->_collapseSingleValueArrays);
     if ($response->getHttpStatus() != 200) {
         throw new Exception('"' . $response->getHttpStatus() . '" Status: ' . $response->getHttpStatusMessage(), $response->getHttpStatus());
     }
     return $response;
 }
開發者ID:andreisavu,項目名稱:solr-php-client-curl,代碼行數:20,代碼來源:Service.php

示例6: _sendRawPost

 /**
  * Central method for making a post operation against this Solr Server
  *
  * @see Apache_Solr_Service::_sendRawGet()
  */
 protected function _sendRawPost($url, $rawPost, $timeout = FALSE, $contentType = 'text/xml; charset=UTF-8')
 {
     $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;
 }
開發者ID:rtanglao,項目名稱:ad6-svn,代碼行數:21,代碼來源:Drupal_Apache_Solr_Service.php

示例7: log

 /**
  * Logs the item and what document was created from it
  *
  * @param	Tx_Solr_IndexQueue_Item	The item that is being indexed.
  * @param	array	An array of Solr documents created from the item's data
  * @param	Apache_Solr_Response	The Solr response for the particular index document
  */
 protected function log(Tx_Solr_IndexQueue_Item $item, array $itemDocuments, Apache_Solr_Response $response)
 {
     if (!$this->loggingEnabled) {
         return;
     }
     $message = 'Index Queue indexing ' . $item->getType() . ':' . $item->getRecordUid() . ' - ';
     $severity = 0;
     // info
     // preparing data
     $documents = array();
     foreach ($itemDocuments as $document) {
         $documents[] = (array) $document;
     }
     $logData = array('item' => (array) $item, 'documents' => $documents, 'response' => (array) $response);
     if ($response->getHttpStatus() == 200) {
         $severity = -1;
         $message .= 'Success';
     } else {
         $severity = 3;
         $message .= 'Failure';
         $logData['status'] = $response->getHttpStatus();
         $logData['status message'] = $response->getHttpStatusMessage();
     }
     \TYPO3\CMS\Core\Utility\GeneralUtility::devLog($message, 'solr', $severity, $logData);
 }
開發者ID:punktDe,項目名稱:solr,代碼行數:32,代碼來源:Indexer.php

示例8: ping

 /**
  * 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;
     }
 }
開發者ID:austinvernsonger,項目名稱:casebox,代碼行數:19,代碼來源:Service.php

示例9: searchByPost

 public function searchByPost($query, $offset = 0, $limit = 10, $params = array())
 {
     if (!is_array($params)) {
         $params = array();
     }
     // construct our full parameters
     // sending the version is important in case the format changes
     $params['version'] = self::SOLR_VERSION;
     // common parameters in this interface
     $params['wt'] = self::SOLR_WRITER;
     $params['json.nl'] = $this->_namedListTreatment;
     $params['q'] = $query;
     $params['start'] = $offset;
     $params['rows'] = $limit;
     //$params['qt'] = 'standard';
     // use http_build_query to encode our arguments because its faster
     // than urlencoding all the parts ourselves in a loop
     $queryString = http_build_query($params, null, $this->_queryStringDelimiter);
     // because http_build_query treats arrays differently than we want to, correct the query
     // string by changing foo[#]=bar (# being an actual number) parameter strings to just
     // multiple foo=bar strings. This regex should always work since '=' will be urlencoded
     // anywhere else the regex isn't expecting it
     $queryString = preg_replace('/%5B(?:[0-9]|[1-9][0-9]+)%5D=/', '=', $queryString);
     $postdata = $queryString;
     $opts = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata));
     $context = stream_context_create($opts);
     //$result = file_get_contents('http://example.com/submit.php', false, $context);
     $response = new Apache_Solr_Response(@file_get_contents($this->_searchUrl, false, $context), $http_response_header, $this->_createDocuments, $this->_collapseSingleValueArrays);
     if ($response->getHttpStatus() != 200) {
         throw new Exception('"' . $response->getHttpStatus() . '" Status: ' . $response->getHttpStatusMessage(), $response->getHttpStatus());
     }
     return $response;
 }
開發者ID:psykomo,項目名稱:kutump-enhanced,代碼行數:33,代碼來源:Service.php

示例10: _sendRawPost

 /**
  * Central method for making a post operation against this Solr Server
  *
  * @param string $sUrl The URL to be requested
  * @param string $sRawPost Workload to be delivered
  * @param float $iTimeLimit Read timeout in seconds
  * @param string $sContentType The content type to be included in the http-header
  * @return Apache_Solr_Response
  *
  * @throws Exception If a non 200 response status is returned by cURL
  */
 protected function _sendRawPost($sUrl, $sRawPost, $iTimeLimit = false, $sContentType = 'text/xml; charset=UTF-8')
 {
     wfProfileIn('BS::' . __METHOD__);
     try {
         if ($iTimeLimit === false) {
             $iTimeLimit = 20;
         }
         $ch = $this->getCurlHandle();
         curl_setopt($ch, CURLOPT_URL, $sUrl);
         curl_setopt($ch, CURLOPT_POST, true);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $sRawPost);
         curl_setopt($ch, CURLOPT_TIMEOUT, $iTimeLimit);
         // maximal exectuion time in seconds
         $data = curl_exec($ch);
         $this->curlConnectionCounter++;
         $data = str_replace("\r\n", "\n", $data);
         $responseParts = explode("\n\n", $data);
         $http_response_header = explode("\n", $responseParts[0]);
         $responseData = isset($responseParts[1]) ? $responseParts[1] : '';
         $response = new Apache_Solr_Response($responseData, $http_response_header, $this->_createDocuments, $this->_collapseSingleValueArrays);
     } catch (Exception $e) {
         wfDebugLog('ExtendedSearch', __METHOD__ . ' Error in _sendRawPost ' . $e->getMessage());
         wfProfileOut('BS::' . __METHOD__);
         return new Apache_Solr_Response('');
     }
     if ($response->getHttpStatus() != 200) {
         wfDebugLog('ExtendedSearch', __METHOD__ . ' Error in _sendRawPost ' . var_export($response, 1));
         wfProfileOut('BS::' . __METHOD__);
         throw new Exception('"' . $response->getHttpStatus() . '" Status: ' . $response->getHttpStatusMessage(), $response->getHttpStatus());
     }
     wfProfileOut('BS::' . __METHOD__);
     return $response;
 }
開發者ID:hfroese,項目名稱:mediawiki-extensions-BlueSpiceExtensions,代碼行數:44,代碼來源:SolrServiceAdapter.class.php

示例11: _sendRawPost

 /**
  * 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;
 }
開發者ID:sascha-egerer,項目名稱:ext-solr,代碼行數:21,代碼來源:Service.php

示例12: _sendRawPost

	/**
	 * Central method for making a post operation against this Solr Server
	 *
	 * @param string $url
	 * @param string $rawPost
	 * @param float $timeout Read timeout in seconds
	 * @param string $contentType
	 * @return Apache_Solr_Response
	 *
	 * @throws Exception If a non 200 response status is returned
	 */
	protected function _sendRawPost($url, $rawPost, $timeout = FALSE, $contentType = 'text/xml; charset=UTF-8')
	{
		//set up the stream context for posting with file_get_contents
		$context = stream_context_create(
			array(
				'http' => array(
					// set HTTP method
					'method' => 'POST',

					// Add our posted content type
					'header' => "Content-Type: $contentType",

					// the posted content
					'content' => $rawPost
				)
			)
		);

		// set the timeout if specified, without this I assume
		// that the default_socket_timeout ini setting is used
		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($context, 'http', 'timeout', $timeout);
		}

		//$http_response_header is set by file_get_contents
		$response = new Apache_Solr_Response(@file_get_contents($url, false, $context), $http_response_header, $this->_createDocuments, $this->_collapseSingleValueArrays);

		if ($response->getHttpStatus() != 200)
		{
			throw new Exception('"' . $response->getHttpStatus() . '" Status: ' . $response->getHttpStatusMessage(), $response->getHttpStatus());
		}

		return $response;
	}
開發者ID:Kervinou,項目名稱:OBM,代碼行數:50,代碼來源:Service.php

示例13: _sendRawPost

 /**
  * Central method for making a post operation against this Solr Server
  *
  * @param string $url
  * @param string $rawPost
  * @param string $contentType
  * @return Apache_Solr_Response
  *
  * @throws Exception If a non 200 response status is returned
  */
 private function _sendRawPost($url, $rawPost, $contentType = 'text/xml; charset=UTF-8')
 {
     //ensure content type is correct
     stream_context_set_option($this->_postContext, 'http', 'header', 'Content-Type: ' . $contentType . "\r\n");
     //set the content
     stream_context_set_option($this->_postContext, 'http', 'content', $rawPost);
     //$http_response_header is set by file_get_contents
     $response = new Apache_Solr_Response(@file_get_contents($url, false, $this->_postContext), $http_response_header);
     if ($response->getHttpStatus() != 200) {
         throw new Exception('"' . $response->getHttpStatus() . '" Status: ' . $response->getHttpStatusMessage());
     }
     return $response;
 }
開發者ID:BGCX067,項目名稱:ezboss-svn-to-git,代碼行數:23,代碼來源:Service.php

示例14: _sendRawPost

 /**
  * 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')
 {
     stream_context_set_option($this->_postContext, array('http' => array('method' => 'POST', 'header' => "Content-Type: {$contentType}", 'content' => $rawPost, 'timeout' => $this->_defaultTimeout)));
     // 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 = (double) $timeout / 2;
         stream_context_set_option($this->_postContext, 'http', 'timeout', $timeout);
     }
     // Proxy settings
     if ($proxyServer = parse_url($GLOBALS['TYPO3_CONF_VARS']['SYS']['curlProxyServer'])) {
         if ($proxyServer['host'] && $proxyServer['port']) {
             stream_context_set_option($this->_postContext, 'http', 'proxy', $proxyServer['host'] . ":" . $proxyServer['port'] . "/");
             stream_context_set_option($this->_postContext, 'http', 'request_fulluri', true);
         }
     }
     // $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;
     //$url = $url . "?commit=true -H \"Content-Type: text/xml\" --data-binary '". $rawPost . "'";
     $response = new Apache_Solr_Response(@file_get_contents($url, false, $this->_postContext), $http_response_header, $this->_createDocuments, $this->_collapseSingleValueArrays);
     //var_dump("Response:" . file_get_contents($url, false, $this->_postContext));
     //exit;
     if ($response->getHttpStatus() != 200) {
         throw new Apache_Solr_HttpTransportException($response);
     }
     return $response;
 }
開發者ID:hkremer,項目名稱:Publieke-Omroep-Typo3,代碼行數:40,代碼來源:Service.php

示例15: reloadCore

 /**
  * Reloads a single Solr core.
  *
  * @param SolrService $solrServer A Solr server connection
  * @param string $coreName Name of the core to reload
  * @return bool TRUE if reloading the core was successful, FALSE otherwise
  */
 protected function reloadCore(SolrService $solrServer, $coreName)
 {
     $coreReloaded = FALSE;
     $path = $solrServer->getPath();
     $pathElements = explode('/', trim($path, '/'));
     $coreAdminReloadUrl = $solrServer->getScheme() . '://' . $solrServer->getHost() . ':' . $solrServer->getPort() . '/' . $pathElements[0] . '/' . 'admin/cores?action=reload&core=' . $coreName;
     $httpTransport = $solrServer->getHttpTransport();
     $httpResponse = $httpTransport->performGetRequest($coreAdminReloadUrl);
     $solrResponse = new \Apache_Solr_Response($httpResponse, $solrServer->getCreateDocuments(), $solrServer->getCollapseSingleValueArrays());
     if ($solrResponse->getHttpStatus() == 200) {
         $coreReloaded = TRUE;
     }
     return $coreReloaded;
 }
開發者ID:nxpthx,項目名稱:ext-solr,代碼行數:21,代碼來源:IndexMaintenanceModuleController.php


注:本文中的Apache_Solr_Response類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。