I'm using elasticsearch 5.2.2 with Laravel 5.4 and I get the following error when I browse http://pr3.app:8000
NoNodesAvailableException in StaticNoPingConnectionPool.php line 51: No alive nodes found in your cluster
- in StaticNoPingConnectionPool.php line 51
- at StaticNoPingConnectionPool->nextConnection() in Transport.php line 72
- at Transport->getConnection() in Transport.php line 90
- at Transport->performRequest('POST', '/people/persons', array(), '{"firstName":"John","lastName":"Doe","gender":"male"}', array()) in Connection.php line 239
- at Connection->Elasticsearch\Connections{closure}(array('transfer_stats' => array('url' => 'http://ift.tt/2lyvYCn', 'content_type' => null, 'http_code' => 0, 'header_size' => 0, 'request_size' => 0, 'filetime' => -1, 'ssl_verify_result' => 0, 'redirect_count' => 0, 'total_time' => 0.004181, 'namelookup_time' => 0.004135, 'connect_time' => 0.0, 'pretransfer_time' => 0.0, 'size_upload' => 0.0, 'size_download' => 0.0, 'speed_download' => 0.0, 'speed_upload' => 0.0, 'download_content_length' => -1.0, 'upload_content_length' => -1.0, 'starttransfer_time' => 0.0, 'redirect_time' => 0.0, 'redirect_url' => '', 'primary_ip' => '', 'certinfo' => array(), 'primary_port' => 0, 'local_ip' => '', 'local_port' => 0, 'error' => 'Failed to connect to pr3.app port 9200: Connection refused', 'errno' => 7), 'curl' => array('error' => 'Failed to connect to pr3.app port 9200: Connection refused', 'errno' => 7), 'effective_url' => 'http://ift.tt/2lyvYCn', 'status' => null, 'reason' => null, 'body' => null, 'headers' => array(), 'error' => object(ConnectException))) in FulfilledPromise.php line 25
- at FulfilledPromise->then(object(Closure), null, null) in CompletedFutureValue.php line 55
- at CompletedFutureValue->then(object(Closure), null, null) in Core.php line 341
- at Core::proxy(object(CompletedFutureArray), object(Closure)) in Connection.php line 294
- at Connection->Elasticsearch\Connections{closure}(array('http_method' => 'POST', 'scheme' => 'http', 'uri' => '/people/persons', 'body' => '{"firstName":"John","lastName":"Doe","gender":"male"}', 'headers' => array('host' => array('pr3.app:9200'), 'Content-type' => array('application/json'), 'Accept' => array('application/json'))), object(Connection), object(Transport), array()) in Connection.php line 171
- at Connection->performRequest('POST', '/people/persons', array(), '{"firstName":"John","lastName":"Doe","gender":"male"}', array(), object(Transport)) in Transport.php line 100
My configuration:
-
In composer.json, I've added
"elasticsearch/elasticsearch": "~5.0"
to"require"
. -
Then I run the command
composer update
. -
To test Elasticsearch, I've written the following in
routes/web.php
Route::get('/', function () {
$es = Elasticsearch\ClientBuilder::create() ->setHosts(['pr3.app:9200']) ->build(); $indexed = $es->index([ 'index' => 'people', 'type' => 'persons', 'body' => [ 'firstName' => 'John', 'lastName' => 'Doe', 'gender' => 'male', ], ]);
});
-
Vagrant is up and is working properly. Elasticsearch also. When I browse http://pr3.app:9200, I can see the following:
{ "name": "FAkNvtq", "cluster_name": "elasticsearch", "cluster_uuid": "M5pNi9p0TF2udk7DNwcFZQ", "version": { "number": "5.2.2", "build_hash": "f9d9b74", "build_date": "2017-02-24T17:26:45.835Z", "build_snapshot": false, "lucene_version": "6.4.1" }, "tagline": "You Know, for Search" }
When I browse http://ift.tt/2lZr8BF, I'm able to see all the documents I created using Postman.
Am I missing something in my config to make ealsticsearch work with Laravel?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire