gpt4 book ai didi

php - 为什么 PHP Solr 扩展给出异常 "Unsuccessful query request"

转载 作者:塔克拉玛干 更新时间:2023-11-03 06:06:01 24 4
gpt4 key购买 nike

我使用 PHP Solr extension当我运行下面的代码时,我得到了异常:

Fatal error: Uncaught exception 'SolrClientException' with message 'Unsuccessful query request : Response Code 404.

不明白,怎么了,我也用solr客户端成功了。

include "bootstrap.php";

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

$client = new SolrClient($options);
$query = new SolrQuery();
$query->setQuery('lucene');
$query->setStart(0);
$query->setRows(50);
$query->addField('cat')->addField('features')->addField('id')-> addField('timestamp');
$query_response = $client->query($query);
$response = $query_response->getResponse();
print_r($response);
?>

我的 bootstrap.php 文件是:

<?php

/* Domain name of the Solr server */
//define('SOLR_SERVER_HOSTNAME', 'solr.example.com');//solr.example.com
define('SOLR_SERVER_HOSTNAME', 'localhost');//solr.example.com


define('SOLR_SECURE', true);


/* HTTP Port to connection */
//define('SOLR_SERVER_PORT', ((SOLR_SECURE) ? 8443 : 8983));
define('SOLR_SERVER_PORT', ((SOLR_SECURE) ? 8080 : 8443));

/* HTTP Basic Authentication Username */
define('SOLR_SERVER_USERNAME', '');//admin

/* HTTP Basic Authentication password */
define('SOLR_SERVER_PASSWORD', '');//changeit

/* HTTP connection timeout */
/* This is maximum time in seconds allowed for the http data transfer operation. Default value is 30 seconds */
define('SOLR_SERVER_TIMEOUT', 10);

/* File name to a PEM-formatted private key + private certificate (concatenated in that order) */
define('SOLR_SSL_CERT', 'certs/combo.pem');

/* File name to a PEM-formatted private certificate only */
define('SOLR_SSL_CERT_ONLY', 'certs/solr.crt');

/* File name to a PEM-formatted private key */
define('SOLR_SSL_KEY', 'certs/solr.key');

/* Password for PEM-formatted private key file */
define('SOLR_SSL_KEYPASSWORD', 'StrongAndSecurePassword');

/* Name of file holding one or more CA certificates to verify peer with*/
define('SOLR_SSL_CAINFO', 'certs/cacert.crt');

/* Name of directory holding multiple CA certificates to verify peer with */
define('SOLR_SSL_CAPATH', 'certs/');

最佳答案

我在查询 Solr 时遇到了类似的错误消息。

错误来自于我正在使用一个集合,因此你需要在你的配置中指定它:

$options = array
(
'hostname' => 'localhost',
'login' => '',
'password' => '',
'port' => 8983,
'path' => 'solr/collection', // <-- Add your collection here
);

关于php - 为什么 PHP Solr 扩展给出异常 "Unsuccessful query request",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13468771/

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