一、代码
二、运行报错
{
"error_code": 999,
"msg": "No alive nodes found in your cluster",
"data": null
}
三、解决方法
我这边地址用的本地的写了https就会有问题
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);
}