StaticNoPingConnectionPool.php中的NoNodesAvailableException:群集中找不到活动节点

时间:2017-09-12 08:37:26

标签: php elasticsearch laravel-5

我使用elasticsearch v 5.5.2和laravel 5.3 - scout v -2.0。

我试图执行下面的代码,但我收到此错误。 NoNodesAvailableException。

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Elasticsearch\ClientBuilder;
use Elastica\Client as ElasticaClient;

class clientController extends Controller
{
    protected $elasticsearch;
    protected $elastica;
    public function __construct()
    {
        $this->elasticsearch = ClientBuilder::create()
                //->setConnectionPool('\Elasticsearch\ConnectionPool\SniffingConnectionPool', [])
                ->build();
        $elasticConfig=['host'=>"locahost",
            "port"=>9200,
            "index"=>'pets'];
        $this->elastica = new  ElasticaClient($elasticConfig);
    }
    public function elasticsearchTest(){

        $param = [
            'index' => 'pets',
            'type' => 'dog',
            'id'=>'1'
        ];
        $res = $this->elasticsearch->get($param);
        dump($res); 
    }
}

错误

  

StaticNoPingConnectionPool.php第51行中的NoNodesAvailableException:   在群集中找不到活动节点

它的工作正常。 结果:

{
   "_index": "pets",
   "_type": "dog",
   "_id": "1",
   "_version": 1,
   "found": true,
   "_source": {
      "name": "tommy",
      "age": "3",
      "color": "black",
      "gender": "male"
   }
}

同时致力于http://localhost:9200/pets/dog/1。 结果:

{"_index":"pets","_type":"dog","_id":"1","_version":1,"found":true,"_source":{
    "name":"tommy",
    "age":"3",
    "color":"black",
    "gender":"male"
}
} 

0 个答案:

没有答案