Why does the PHP Solr extension throw a Failed Request Request exception

I am using the PHP Solr extension , and when I run the code below, I get an exception:

Fatal error: throw a SolrClientException exception with the message "Request failed request: Response code 404.

I do not understand what is wrong, I also successfully use the Solr client.

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

my bootstrap.php file is:

 <?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
source share
2 answers

I had a similar error message when I request Solr.

The error came from the fact that I am using a collection, and therefore you need to specify it in your configuration:

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

What I see as a problem is the line

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

Is your secure connection using port 8080 or 8443? I assume that the normal connection is 8080 and the safe is 8443, but the line implies the opposite: the secure port is 8080 and the normal is 8443

+1
source

Source: https://habr.com/ru/post/1447158/


All Articles