elasticsearch - yii2 弹性搜索 | 确保 GET /_nodes
问题描述
我安装了 elasticsearch 并尝试发出请求,但作为响应我收到错误
Cluster autodetection did not find any active node. Make sure a GET /_nodes reguest on the hosts defined in the config returns the "http_address" field for each node.
当我运行命令时CURL -X GET http://localhost:9200
{
"name" : "DS12IC4",
"cluster_name" : "elasticsearch_denysmaksiura",
"cluster_uuid" : "YzFUXRS6SPmObJcC4bv_ag",
"version" : {
"number" : "6.8.5",
"build_flavor" : "oss",
"build_type" : "tar",
"build_hash" : "78990e9",
"build_date" : "2019-11-13T20:04:24.100411Z",
"build_snapshot" : false,
"lucene_version" : "7.7.2",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}
我的 main.php 文件
'elasticsearch' => [
'class' => 'yii\elasticsearch\Connection',
'nodes' => [
['http_address' => 'localhost:9200'],
// configure more hosts if you have a cluster
],
],
我的控制器
$model = new SearchAllForms();
$dataProvider = $model->globalSearch(Yii::$app->request->queryParams);
echo"<pre>";
var_dump($dataProvider->getModels());
exit;
我的模型(测试请求)
$query = $this::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
'key' => 'id'
]);
$query->query(['match' => ['name' => 'Гидротест']]);
return $dataProvider;
如何消除此错误?
解决方案
yiisoft/yii2-elasticsearch 中有 2.1-dev 版本。这个问题在那里解决了。请检查这个版本。
推荐阅读
- javascript - 将回调转换为承诺的问题
- python - PyCharm 找不到 virtualenv 解释器
- javascript - 使用另一台电脑登录另一个不同的帐户后,当前的 PHP SESSION 被替换
- python - 基于“是”或“否”响应重复的硬币翻转程序
- php - 将字符串声明转换为特征中的成员
- php - 如何执行条件查询
- python - 通过 python Requests 或 urllib 发送 Soap 1.1 请求
- c++ - 在(未)定义(非)默认构造函数时声明类的对象数组?
- linux - 查找具有条件的最大文件并将其复制到特定目录
- java - 在 macOS 上删除旧的 Java 安装