gpt4 book ai didi

PHP Solr Xpath错误: no elements found

转载 作者:行者123 更新时间:2023-12-02 02:35:31 29 4
gpt4 key购买 nike

https://github.com/php/pecl-search_engine-solr/blob/master/solr_functions_client.c#L564

PECL信息

Installed packages, channel pecl.php.net:
=========================================
solr 2.0.0 stable

PHP版本5.3.6

Solr版本4.9.0

我正在使用该程序的全新安装,使用/example/start.jar 包,没有更改任何配置。管理面板完全正常。但是,围绕该技术构建的应用程序在尝试执行基于 Lucene 的查询时返回以下错误:

PHP Warning:  SolrClient::query(): Xpath Error: no elements found

Solr 在我的本地环境中运行,区别在于 PHP 版本,设置为 5.5.9-1ubuntu4.3。这可能是一个因素吗?

最佳答案

我也遇到了同样的问题,我的问题如下:问题是它没有找到相应的solr核心/集合。php solr 实现(接缝)默认使用名为“collection1”的核心,如果该核心不存在,则会发生错误“Xpath 错误:未找到元素”。

要解决此问题,您可以将 PATH 设置为您使用的集合/核心名称。如果执行查询,您必须将路径设置为 http://host:port 之后的 URL 部分,如您在 Solr Admin 中看到的那样。例子:你的核心被命名为“食谱”,查询网址为:http://localhost:8983/solr/recipes/select?q=*%3A*&wt=json&indent=true所以你需要路径“/solr/recipes”

要设置路径,您可以执行以下操作:(基于 http://php.net/manual/en/solr.examples.php )

define('SOLR_PATH', '/solr/recipes');

$options = array
(
'hostname' => SOLR_SERVER_HOSTNAME,
'login' => SOLR_SERVER_USERNAME,
'password' => SOLR_SERVER_PASSWORD,
'port' => SOLR_SERVER_PORT,
'path' => SOLR_PATH,
);

$client = new SolrClient($options);

$doc = new SolrInputDocument();

$doc->addField('id', 334455);
$doc->addField('cat', 'Software');
$doc->addField('cat', 'Lucene');

$updateResponse = $client->addDocument($doc);

print_r($updateResponse->getResponse());

关于PHP Solr Xpath错误: no elements found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25343543/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com