Elasticsearch7.15.2 No alive nodes found in your cluster

359 阅读1分钟

一、代码

image.png

二、运行报错

image.png

{
    "error_code": 999,
    "msg": "No alive nodes found in your cluster",
    "data": null
}

三、解决方法

我这边地址用的本地的写了https就会有问题

image.png

public function index()
{
    $hosts = [
        'localhost:9200'
    ];
    $client = ClientBuilder::create()
        ->setHosts($hosts)
        ->build();
    // 创建索引
    $params = [
        'index' => 'seckill_goods',
        'body' => [
            'settings' => [
                'number_of_shards' => 5,
                'number_of_replicas' => 1
            ],
            'mappings' => [
                '_source' => [
                    'enabled' => true
                ],
                'properties' => [
                    'name' => [
                        'type' => 'text',//相当于mysql中like检索
                        'analyzer' => 'ik_max_word',
                        'search_analyzer' => 'ik_max_word'
                    ]
                ]
            ]
        ]
    ];
    $response = $client->indices()->create($params);
    print_r($response);
}