有关solr服务的问题

时间:2016-06-13 09:50:35

标签: php search solr

我正面临Solr 6.0.1的问题,我正在尝试为我的网站实施搜索功能。所以后来我跟进了这个site中给出的指示。但现在我正面临这个错误

Solr service is not available

 Fatal error: Uncaught exception 'Apache_Solr_HttpTransportException' with message ''404' Status: Not Found' in /Users/Tanishq/Sites/SolrPHPClient/Apache/Solr/Service.php:338 Stack trace: #0 /Users/Tanishq/Sites/SolrPHPClient/Apache/Solr/Service.php(1209): Apache_Solr_Service->_sendRawGet('http://localhos...') #1 /Users/Tanishq/Sites/results.php(16): Apache_Solr_Service->search('ok', 0, 10) #2 {main} thrown in /Users/Tanishq/Sites/SolrPHPClient/Apache/Solr/Service.php on line 338

以下是来自service.php

的行
338:     throw new Apache_Solr_HttpTransportException($solrResponse);

1209: return $this->_sendRawGet($this->_searchUrl.$this->_queryDelimiter.$queryString);

这是我result.php

的代码
<?php
if(!isset($_REQUEST['query']) || empty($_REQUEST['query']))
   {
header('Location: http://localhost/~Tanishq/search.php ');
}
else
{
    $query = $_REQUEST['query'];
}
require_once('constants.php');
require_once('SolrPHPClient/Apache/Solr/Service.php');
$solr = new Apache_Solr_Service(SOLRHOST, SOLRPORT, SOLRNAME);
     if( ! $solr->ping()) { 
        echo 'Solr service is not available'; 
    } 
$results = $solr->search($query, 0, 10);  

if(empty($results))
{
    echo "not available";
}
else echo "Displaying";
echo '<table>';
echo '<tr><th>ID</th>' .
'<th>Name</th>' .
'<th>Description</th>' .
'<th>Price</th></tr>';
 {
  foreach($results->response->docs as $doc)
  {
      echo '<tr><td>'.htmlspecialchars($doc->id).'</td>' .
           '<td>'.htmlspecialchars($doc->product_name).'</td>'.
           '<td>'.htmlspecialchars($doc->product_description).'</td>'.
           '<td>'.htmlspecialchars($doc->product_price).'</td></tr>';
}
}
echo '</table>';

?>

0 个答案:

没有答案