4

PHP Solr拡張機能を使用していますが、以下のコードを実行すると例外が発生します:

致命的なエラー: キャッチされない例外 'SolrClientException' とメッセージ 'クエリ要求が失敗しました: 応答コード 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/');
4

2 に答える 2

8

Solr にクエリを実行すると、同様のエラー メッセージが表示されました。

コレクションを使用しているため、構成で指定する必要があるため、エラーが発生しました。

$options = array
(
        'hostname' => 'localhost',
        'login'    => '',
        'password' => '',
        'port'     => 8983,
        'path'     => 'solr/collection', // <-- Add your collection here
);
于 2014-09-01T05:47:11.430 に答える
1

私が問題として見ることができるのは、行です

define('SOLR_SERVER_PORT', ((SOLR_SECURE) ? 8080 : 8443));

ポート 8080 または 8443 を使用した安全な接続ですか? 通常の接続は 8080 でセキュアは 8443 であると仮定しますが、行は逆を意味し、セキュア ポートは 8080 で通常の接続は 8443 です。

于 2012-11-20T13:45:56.253 に答える