嗨团队我已经完成了一个在本地机器上工作的 solr 搜索模块。但是,当上传到服务器时,它会在 php 页面中引发通信错误..
我正在使用这样的代码
header('Content-Type: text/html; charset=utf-8');
$limit = 1000;
$query = isset($_REQUEST['q']) ? $_REQUEST['q']: false;
$results = false;
$sdk=$_REQUEST['q'].$_REQUEST['fq'];
if ($query)
{
require_once('Apache/Solr/Service.php');
//changed from $solr = new Apache_Solr_Service('localhost', 8180, '/solr/'); to
$solr = new Apache_Solr_Service('index.websolr.com', 8180, '/solr/231sd3123');
if (get_magic_quotes_gpc() == 1)
{
echo $query = stripslashes($query);
}
try
{
$results = $solr->search($query, 0, $limit);
}
catch (Exception $e)
{
die("<html><head><title>SEARCH EXCEPTION</title><body><pre>{$e->__toString()}</pre></body></html>");
}
}
// display results
if ($results)
{
$total = (int) $results->response->numFound;
$start = min(1, $total);
$end = min($limit, $total);
?>
<?php
// iterate result documents
foreach ($results->response->docs as $doc)
{
//getting objects by field names and their values then filtering to our requirment
foreach ($doc as $field => $value)
{
if($field== "id")
{
$id = htmlspecialchars($value, ENT_NOQUOTES, 'utf-8');
}
if($field== "name")
{
$name = htmlspecialchars($value, ENT_NOQUOTES, 'utf-8');
}
if($field== "description")
{
$description = htmlspecialchars($value, ENT_NOQUOTES, 'utf-8');
$des = $description;
}
if($field== "level")
{
$level = htmlspecialchars($value, ENT_NOQUOTES, 'utf-8');
}
if($field== "download_link")
{
$download_line = htmlspecialchars($value, ENT_NOQUOTES, 'utf-8');
}
if($field== "source_code_link")
{
$source_code_link = htmlspecialchars($value, ENT_NOQUOTES, 'utf-8');
}
}
?>
<a href="codelisting.php?q=<?php echo $sdk; ?>&id=<?php echo $id; ?>&source=<?php echo $source_code_link; ?> "><p><?php echo $name ?></p></a>
<?php
}
}
?>
这是 Service.php 中指出的部分
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;
}
我不知道我在哪里失踪......任何帮助表示赞赏......