php - Elasticsearch PHP 客户端抛出异常 "No alive nodes found in your cluster"

标签 php elasticsearch php-5.6

我正在尝试对索引进行扫描和滚动操作,如 example 中所示:

$client = ClientBuilder::create()->setHosts([MYESHOST])->build();
$params = [
    "search_type" => "scan",    // use search_type=scan
    "scroll" => "30s",          // how long between scroll requests. should be small!
    "size" => 50,               // how many results *per shard* you want back
    "index" => "my_index",
    "body" => [
        "query" => [
            "match_all" => []
        ]
    ]
];

$docs = $client->search($params);   // Execute the search
$scroll_id = $docs['_scroll_id'];   // The response will contain no results, just a _scroll_id

// Now we loop until the scroll "cursors" are exhausted
while (\true) {

    // Execute a Scroll request
    $response = $client->scroll([
            "scroll_id" => $scroll_id,  //...using our previously obtained _scroll_id
            "scroll" => "30s"           // and the same timeout window
        ]
    );

    // Check to see if we got any search hits from the scroll
    if (count($response['hits']['hits']) > 0) {
        // If yes, Do Work Here

        // Get new scroll_id
        // Must always refresh your _scroll_id!  It can change sometimes
        $scroll_id = $response['_scroll_id'];
    } else {
        // No results, scroll cursor is empty.  You've exported all the data
        break;
    }
}

第一个 $client->search($params) API 调用执行良好,我能够取回滚动 ID。但是 $client->scroll() API 失败,我收到异常:“Elasticsearch\Common\Exceptions\NoNodesAvailableException No alive nodes found in your cluster”

我正在使用 Elasticsearch 1.7.1 和 PHP 5.6.11

请帮忙

最佳答案

我发现 elasticsearch 的 php 驱动程序充满了问题,我的解决方案是通过 php 实现带有 curl 的 RESTful API,一切都运行得更快,调试也更容易

关于php - Elasticsearch PHP 客户端抛出异常 "No alive nodes found in your cluster",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32581905/

相关文章:

PHP 向服务器发送空表单值

php - 从MySQL获取值,并将它们放入其他表中(一次多个值)

php - @include 如何在 laravel 中工作?

php - 用于匹配值并替换为特定相关值的正则表达式规则

php - 当我使用PDO时我应该使用addslashes函数吗?

elasticsearch - 无法让 Elasticsearch Highlight 工作

php - 如何设置 Facebook 返回 URL

ruby-on-rails - 是否可以在本地重现429错误(请求过多)?

elasticsearch - 根据字段的存在提升文档

php - 解决 php-common 冲突的最佳方法 : ignore, 修复,其他?