【发布时间】:2021-02-06 18:42:22
【问题描述】:
我有一个带有 ElasticSearch 的 Docker 容器,当我转到 localhost: 9200 时,我看到以下内容
{
"name" : "16ea4fe71ce8",
"cluster_name" : "docker-cluster",
"cluster_uuid" : "_na_",
"version" : {
"number" : "7.0.1",
"build_flavor" : "default",
"build_type" : "docker",
"build_hash" : "e4efcb5",
"build_date" : "2019-04-29T12:56:03.145736Z",
"build_snapshot" : false,
"lucene_version" : "8.0.0",
"minimum_wire_compatibility_version" : "6.7.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
好的,我认为我的弹性容器正在工作。接下来,我安装这两个包 https://github.com/elastic/elasticsearch-php https://github.com/cviebrock/laravel-elasticsearch
在.env文件中,我设置了环境变量
ELASTICSEARCH_HOST=localhost
ELASTICSEARCH_PORT=9200
ELASTICSEARCH_SCHEME=http
ELASTICSEARCH_USER=
ELASTICSEARCH_PASS=
我写了一个简单的方法来检查我在那里做了什么
public function esSearch() {
$data = [
'body' => [
'testField' => 'abc'
],
'index' => 'my_index',
'type' => 'my_type',
'id' => 'my_id',
];
$client = ClientBuilder::create()->build();
$return = $client->index($data);
dd($return);
}
因此,我收到错误 No alive nodes found in your cluster
请告诉我如何交朋友 ElasticSearch 和 Laravel 8?我尝试使用来自 GitHub 的不同包,但大多数都不支持 Laravel 8。也许有一些关于如何使用 ES 和 Laravel 的指南?
【问题讨论】:
-
你的 lavarel 是否也在 docker conatiner 中运行?
-
是的,在 docker 容器中
标签: php laravel elasticsearch