简体   繁体   English

是否需要使用独立的码头安装来使用php pecl solr扩展?

[英]Is it necessary to use a standalone jetty install for using the php pecl solr extension?

I am currently just running the "start.jar" in the "example" folder of the solr folder. 我目前仅在solr文件夹的“ example”文件夹中运行“ start.jar”。 While trying to contact solr using the pecl solr extension from PHP, i am getting exceptions in the "php_solr_client.c" file in the extension installation. 尝试使用来自PHP的pecl solr扩展联系solr时,我在扩展安装的“ php_solr_client.c”文件中遇到异常。 I am using SOLR 3.1, I believe the config is correct.. "hostname" - localhost, port - 8983, path - '/solr/' 我正在使用SOLR 3.1,我相信配置是正确的。“主机名”-本地主机,端口-8983,路径-'/ solr /'

I can access solr admin at "http://localhost:8983/solr/admin/" 我可以通过“ http:// localhost:8983 / solr / admin /”访问solr admin

What i'm worried about is that my machine doesn't list 8983 as an open port. 我担心的是我的机器没有将8983列为开放端口。 Isn't this weird. 这不是很奇怪吗? ? This is my connection config.. 这是我的连接配置。

<?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());
?>

This is the output i get. 这是我得到的输出。

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)

SolrClient doesn't care where your Solr installation lives or what serves it up. SolrClient不在乎您的Solr安装SolrClient何处或为它提供服务。 You can define the connection parameters in the constructor . 您可以在构造函数中定义连接参数。

If you are having trouble connecting, check that the parameters you're using for the thing hosting Solr, be it Jetty or a baked potato, match up with the parameters you're passing to the constructor. 如果连接时遇到问题,请检查用于托管Solr的东西的参数(无论是Jetty还是烤土豆),并与传递给构造函数的参数匹配。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM