我試圖做一個索引掃描和滾動操作,如圖中的「在集羣中沒有發現活節點」的example:Elasticsearch PHP客戶端引發異常
$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 \例外\ NoNodesAvailableException在集羣中沒有發現活節點」
我使用Elasticsearch 1.7.1和PHP 5.6.11
請幫助
你有沒有得到答案,我有一個本地節點無法找到,這是相當煩人。 –
@MrkFldig還沒有人回答 – ajaybc
等待我發現了一些你可以嘗試的東西... –