【发布时间】:2016-03-23 07:08:45
【问题描述】:
我正在为我的一个项目使用 solr 服务器。手动导入和查询选择工作正常。我也能够从 solr 服务器获得结果。 实际问题是,每当我尝试使用PHP-SolrClient 更新 solr 服务器时,它都会返回错误。 我使用下面给出的查询进行 solr 更新的代码。
$options = array(
'hostname' => 'xxx.xxx.xxx.xxx',
'login' => '',
'password' => '',
'port' => 8983);
$client = new SolrClient($options);
$client->ping();
但是代码返回以下错误。
警告:SolrClient::ping():实体:第 1 行:解析器错误:需要开始标记,在第 132 行调用堆栈:0.0095 234296 1 的 /var/www/html/test.php 中找不到“ping() /var/www/html/test.php:132 警告:SolrClient::ping(): HTTP/ 1.1 404 Not Found in /var/www/html/test.php on line 132 Call Stack: 0.0095 234296 1. {main}() /var/www/html/test.php:0 0.0096 237776 2. SolrClient->ping () /var/www/html/test.php:132 警告:SolrClient::ping(): ^ in /var/www/html/test.php 第 132 行调用堆栈:0.0095 234296 1. {main}() /var/www/html/test.php:0 0.0096 237776 2. SolrClient->ping() /var/www/html/test.php:132 警告:SolrClient::ping(): Xpath 错误:在中找不到元素/var/www/html/test.php 在第 132 行调用堆栈:0.0095 234296 1. {main}() /var/www/html/test.php:0 0.0096 237776 2. SolrClient->ping() /var/ www/html/test.php:132 致命错误:第 1 行 /var/www/html/test.php 中带有消息的未捕获异常 'SolrClientException' 32 SolrClientException:不成功的 ping 请求:响应代码 404。HTTP/1.1 404 Not Found Content-Type: text/html; charset=ISO-8859-1 Cache-Control: must-revalidate,no-cache,no-store Content-Length: 300 in /var/www/html/test.php on line 132 Call Stack: 0.0095 234296 1. {main }() /var/www/html/test.php:0 0.0096 237776 2. SolrClient->ping() /var/www/html/test.php:132
谁能帮我找出导致错误的原因?
【问题讨论】:
-
让我们知道您在
test.php脚本中的第 132 行有什么内容 :) -
@mitkosoft 第 132 行有
$client->ping(); -
确实,我不知道你为什么需要这样的客户? Solr http api 已经够用了,你可以设置它的输出为多种形式,如 Ajax、xml、php 数组等,使用
file_get_content一切都会很方便。