首页 > 解决方案 > 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;

如何消除此错误?

标签: elasticsearchyii2

解决方案


yiisoft/yii2-elasticsearch 中有 2.1-dev 版本。这个问题在那里解决了。请检查这个版本。


推荐阅读