【问题标题】:Is it necessary to use a standalone jetty install for using the php pecl solr extension?是否有必要使用独立的码头安装来使用 php pecl solr 扩展?
【发布时间】:2012-12-17 07:09:28
【问题描述】:

我目前只是在 solr 文件夹的“example”文件夹中运行“start.jar”。 在尝试使用 PHP 的 pecl solr 扩展联系 solr 时,我在扩展安装的“php_solr_client.c”文件中遇到异常。 我正在使用 SOLR 3.1, 我相信配置是正确的..“主机名” - localhost,端口 - 8983,路径 - '/solr/'

我可以通过“http://localhost:8983/solr/admin/”访问 solr 管理员

我担心的是我的机器没有将 8983 列为开放端口。这不是很奇怪吗。 ? 这是我的连接配置..

<?php
$options = array
(
 'hostname' => 'localhost',
 'port'     => 8983,
 'path'     => '/solr/'
 );

$client = new SolrClient($options);

$doc = new SolrInputDocument();

$doc->addField('id', 334455);
var_dump($doc->toArray());
try{
$pingresponse   = $client->ping();
$updateResponse = $client->addDocument($doc);
}
catch(Exception $e){
        var_dump($e->getInternalInfo());
}
//print_r($updateResponse->getResponse());
?>

这是我得到的输出。

array (size=3)
  'document_boost' => float 0
  'field_count' => int 1
  'fields' => 
    array (size=1)
      0 => 
        object(SolrDocumentField)[3]
          public 'name' => string 'id' (length=2)
          public 'boost' => float 0
          public 'values' => 
            array (size=1)
              ...

( ! ) Warning: SolrClient::ping(): in /var/www/html/simple/new.php on line 16
Call Stack
#   Time    Memory  Function    Location
1   0.0003  234560  {main}( )   ../new.php:0
2   0.0005  239096  SolrClient->ping( ) ../new.php:16

array (size=3)
  'sourceline' => int 1704
  'sourcefile' => string '/builddir/build/BUILD/php-pecl-solr-1.0.2/solr-1.0.2/php_solr_client.c' (length=70)
  'zif_name' => string 'zim_SolrClient_ping' (length=19)

【问题讨论】:

    标签: php solr jetty pecl


    【解决方案1】:

    SolrClient 不关心您的 Solr 安装在哪里或为它提供什么服务。可以定义连接参数in the constructor

    如果您在连接时遇到问题,请检查您用于托管 Solr 的参数(无论是 Jetty 还是烤土豆)与您传递给构造函数的参数是否匹配。

    【讨论】:

    • 如果我可以在“localhost:8983/solr”访问solr“欢迎页面”,我的“路径”和“主机名”应该是什么?我是否需要定义数组中所需的所有参数..?
    • read about the components in URIs,然后你就会明白http://localhost:8983/solr/的各个部分叫什么了。这是您应该已经具备的基本互联网知识。
    • 我知道,我很困惑的是我是否必须将扩展名指向 solr 的主目录。 ?事情是这样配置的,但它不起作用。
    • 使用您用于连接的代码编辑您的问题,并提供完整而准确的错误消息 -- 复制和粘贴。不要总结,不要缩短。
    • 如何转储实际的Exception
    猜你喜欢
    • 1970-01-01
    • 2019-04-13
    • 2023-04-08
    • 2020-12-27
    • 2013-04-18
    • 2010-10-15
    • 2010-10-08
    • 2010-12-31
    • 1970-01-01
    相关资源
    最近更新 更多