更新文档时出现Solr错误


Solr error when update a document

我已经使用这段代码开始我的新的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);
$doc = new SolrInputDocument();
/*$doc->addField('idDocument', 1);
$doc->addField('titleFr', 'Le petit poucet');
*/
$doc->addField(utf8_encode('idDocument'), utf8_encode(1));
$doc->addField(utf8_encode('titleFr'), utf8_encode('Le petit poucet'));
var_dump($doc->getFieldNames());
$updateResponse = $client->addDocument($doc, true, 10000);
//$client->commit();
var_dump($updateResponse->getResponse());

My BootStrap.php是:

/* Nom de domaine du serveur Solr */
define('SOLR_SERVER_HOSTNAME', 'localhost:81/solr/#/testDocument/');
/* Si l'on doit exécuter en mode sécurisé ou non */
define('SOLR_SECURE', true);
/* Port HTTP de connexion */
define('SOLR_SERVER_PORT', ((SOLR_SECURE) ? 8443 : 8983));
/* Nom d'utilisateur pour l'authentification HTTP Basic */
define('SOLR_SERVER_USERNAME', 'admin');
/* Mot de passe pour l'authentification HTTP Basic */
define('SOLR_SERVER_PASSWORD', '');
/* Délai maximal de connexion HTTP */
/* C'estla durée maximale en secondes autorisée pour l'opération de transfert de données http. La valeur par défaut est 30 secondes */
define('SOLR_SERVER_TIMEOUT', 10);
/* Nom du fichier de la clé privée formattée PEM + du certificat privé (concaténés dans cet ordre) */
define('SOLR_SSL_CERT', 'certs/combo.pem');
/* Nom du fichier du certificat privé formatté PEM seulement */
define('SOLR_SSL_CERT_ONLY', 'certs/solr.crt');
/* Nom du fichier de la clé privée formattée PEM */
define('SOLR_SSL_KEY', 'certs/solr.key');
/* Mot de passe pour le fichier de la clé privée formattée PEM */
define('SOLR_SSL_KEYPASSWORD', 'StrongAndSecurePassword');
/* Nom du fichier contenant un ou plusieurs certificats CA pour l'authentification */
define('SOLR_SSL_CAINFO', 'certs/cacert.crt');
/* Nom du dossier contenant les certificats CA pour l'authentification */
define('SOLR_SSL_CAPATH', 'certs/');

当我使用它的时候。我有这个错误和其他错误。Warning: SolrClient::addDocument(): Entity: line 4: parser error : Input is not proper UTF-8, indicate encoding ! Bytes: 0xE9 0x74 0x68 0x6F in C:'wamp'www'testAntoine2'send.php on line 76

我使用Bitnami Apache solR堆栈,我完全被这个错误阻塞。你能帮我吗?你能给我一些新的建议吗?

最诚挚的问候,Uruca:)

您的Solr URL包含"/#/"…这是一个URL,将只有工作在一个完整的图形化浏览器——它是管理UI的一部分。当运行管理UI与Solr进行API通信时,不能使用浏览器中看到的url。

如果"testDocument"是Solr内核的名称(或SolrCloud安装的集合),那么这是Solr的URL:

localhost: 81/solr/testDocument/

我不能确定你正在使用什么PHP Solr客户端,但是对于$options变量,我相信你应该只有"localhost"作为主机名,port中正确的端口号,和"/Solr/testDocument"作为路径。当前您根本没有路径。

我这里有一些困惑…对于主机名,您有一个包含端口81的URL,但是对于端口,您使用8443或8983。哪一个才是真正的港口?