/*
$params['refresh'] = (boolean) Should the effected indexes be refreshed?
['timeout'] = (time) Time each individual bulk request should wait for shards that are unavailable
['consistency'] = (enum) Explicit write consistency setting for the operation
['wait_for_completion'] = (boolean) Should the request should block until the reindex is complete
['requests_per_second'] = (float) The throttle for this request in sub-requests per second. 0 means set no throttle
['body'] = (array) The search definition using the Query DSL and the prototype for the index request (Required)
['body'] = (array) Request body
*/
$params = [
// ...
];
$client = ClientBuilder::create()->build();
$response = $client->reindex($params);Elasticsearch版本为5.6.13。
我试图使用上面PHP客户端的reindex API将源索引重新索引到目标索引。sourceIndex只有1个文档。
请求:
$params = [
'body' => [
'source' => [
'index' => 'sourceIndex',
],
'dest' => [
'index' => 'destIndex'
]
]
];
$response = $client->reindex($params);响应:
(
[took] => 2
[timed_out] =>
[total] => 0
[updated] => 0
[created] => 0
[deleted] => 0
[batches] => 0
[version_conflicts] => 0
[noops] => 0
[retries] => Array
(
[bulk] => 0
[search] => 0
)
[throttled_millis] => 0
[requests_per_second] => -1
[throttled_until_millis] => 0
[failures] => Array
(
)
)如您所见,重新索引的文档是0(总=>为0)。
使用Kibana的DevTool可以很好地工作,但使用elasticsearch-php客户端就不行了。
POST _reindex
{
"source": {
"index": "sourceIndex"
},
"dest": {
"index": "destIndex"
}
}任何帮助都是非常感谢的。如果你需要更多细节来帮助回答这个问题,请让我知道。
发布于 2018-11-17 04:31:42
仅供参考-以防有人碰巧面临同样的问题。问题是源索引的refresh_interval设置为-1。要使reindex操作生效,只需在调用_reindex接口之前刷新源索引即可。
https://stackoverflow.com/questions/53321777
复制相似问题