首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Elasticsearch-PHP reindex未按预期工作

Elasticsearch-PHP reindex未按预期工作
EN

Stack Overflow用户
提问于 2018-11-15 22:35:25
回答 1查看 467关注 0票数 0

reindex接口文档:https://www.elastic.co/guide/en/elasticsearch/client/php-api/6.0/ElasticsearchPHP_Endpoints.html#Elasticsearch_Clientreindex_reindex

代码语言:javascript
复制
/*
$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个文档。

请求:

代码语言:javascript
复制
$params = [
    'body' => [
        'source' => [
            'index'  => 'sourceIndex',
        ],
        'dest' => [
            'index' => 'destIndex'
        ]
    ]
];
$response = $client->reindex($params);

响应:

代码语言:javascript
复制
(
    [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客户端就不行了。

代码语言:javascript
复制
POST _reindex
{
  "source": {
    "index": "sourceIndex"
  },
  "dest": {
    "index": "destIndex"
  }
}

任何帮助都是非常感谢的。如果你需要更多细节来帮助回答这个问题,请让我知道。

EN

回答 1

Stack Overflow用户

发布于 2018-11-17 04:31:42

仅供参考-以防有人碰巧面临同样的问题。问题是源索引的refresh_interval设置为-1。要使reindex操作生效,只需在调用_reindex接口之前刷新源索引即可。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53321777

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档