我正在使用Solr PHP Client
并Solr 4.3.0
启动并运行示例。我没有修改schema.xml
文件。当我运行此代码时,出现400
错误:
Uncaught exception 'Apache_Solr_HttpTransportException' with message '400' Status: Bad Request.'
该文档未显示在索引中。有趣的是,如果我重新启动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`