2013-05-16 4 views
2

나는 Solr PHP Client을 사용 중이며 Solr 4.3.0 예제를 실행 중입니다. schema.xml 파일을 수정하지 않았습니다.Solr PHP 클라이언트를 사용한 색인 데이터

Uncaught exception 'Apache_Solr_HttpTransportException' with message '400' Status: Bad Request.' 

이 문서는 색인에 표시되지 않습니다 :이 코드를 실행하면 나는 400 오류가 발생합니다. 흥미롭게도 Jetty을 다시 시작하면 문서의 색인이 생성됩니다. 여기 내 코드가있다. 내가 뭔가를 놓치고 있는지 궁금해서. 이것이 스키마와 일치하는 입력과 관련된 문제라고 생각했지만 id이 유일한 필수 필드 인 것으로 보이며 다른 필드는 스키마에 있습니다. 나는 무엇을해야할지 모르겠습니다.

require_once('SolrPhpClient/Apache/Solr/Service.php'); 

$solr = new Apache_Solr_Service('localhost', 8983, '/solr/'); 

if($solr->ping() == null){ 
    die('could not ping solr'); 
} 

$document = new Apache_Solr_Document(); 
$document->id = 'guid1'; 
$document->title = 'Title1'; 
$document->subject = 'The subject is solr'; 
$document->description = 'This is the description'; 

$solr->addDocument($document); 
$solr->commit(); 

내가 얻을 전체 오류 메시지가

Fatal error: Uncaught exception 'Apache_Solr_HttpTransportException' with message ''400' Status: Bad Request' in C:\xampp\htdocs\dev\SolrPhpClient\Apache\Solr\Service.php:364 
Stack trace: 
#0 C:\xampp\htdocs\dev\SolrPhpClient\Apache\Solr\Service.php(829): Apache_Solr_Service->_sendRawPost('http://localhos...', '<commit expunge...', 3600) 
#1 C:\xampp\htdocs\dev\indexerSOLR_PHP.php(20): Apache_Solr_Service->commit() 
#2 {main} thrown in C:\xampp\htdocs\dev\SolrPhpClient\Apache\Solr\Service.php on line 364` 
+0

동일한 코드를 사용하여 데이터를 커밋하지만 Solr Admin에서 여전히 검색 할 수 없습니다. 네가이 일을 끝내면 나 좀 도와 줄 수있어? – AppleBud

답변

4

이 SOLR 4.x의 알려진 문제이며, SOLR PHP 클라이언트에서 커밋 부르고있다. 자세한 내용과 문제를 해결하기위한 패치는 Bug #62332 - As of solr 4.0 the waitFlush parameter is removed for commit을 참조하십시오.

+0

고마워요! 패치 적용 방법을 알고 있습니까? 확장 기능 이름을 변경하면 실행할 수있는 쉘 스크립트입니까? Solr-PHP 클라이언트가 패치를 적용한 것입니다. 그렇습니까? 솔, 아니야? – user1521567

+0

오, 그 패치를 얻는 PECL Solr PHP 확장. 이것은 복잡해질 것 같습니다. :( – user1521567

+0

Service.php 파일을 필요한 변경 사항이있는이 파일과 비교할 수 있습니다. https://code.google.com/p/solr-php-client/ source/browse/trunk/Apache/Solr/Service.php # 821 그리고 로컬 복사본을 수정하십시오. –

2

이것이 내가 어떻게 해결책을 얻었는지, 나는 커밋 방법을 수정했다. _updateurl 변수에 '& commit = true'를 추가했습니다.

public function commit($expungeDeletes = false, $waitFlush = true, $waitSearcher = true, $timeout = 3600) 
{ 
    $expungeValue = $expungeDeletes ? 'true' : 'false'; 
    $flushValue = $waitFlush ? 'true' : 'false'; 
    $searcherValue = $waitSearcher ? 'true' : 'false'; 

    //$rawPost = '<commit expungeDeletes="' . $expungeValue . '" waitFlush="' . $flushValue . '" waitSearcher="' . $searcherValue . '" />'; 
      //$this->post=$rawPost;   
    return $this->_sendRawGet($this->_updateUrl.'&commit=true', $timeout); 
} 
0

이 행은 변경되었습니다.

require_once ('SolrPhpClient/Apache/Solr/Service.php'); => require_once ('Service.php');

아마도이 파일의 경로가 잘못되었습니다. 나는이 줄을 바꾸려고 노력했다. 그런 다음 성공적으로 작동합니다.

0

이전 버전의 PHP Solr 확장 (0.9.11)을 설치했기 때문에 동일한 문제가 발생했습니다.

는 최신 하나 얻으려면 :

pecl download solr-beta 
tar xvzf solr-2.1.0.tgz # This can be different depending on the last release number 
cd solr-2.1.0/ 
phpize 
./configure 
make 
sudo make install 
# add extension=solr.so to your php.ini/distribution extension loader 

감사를 this post에.