【问题标题】:Elasticsearch reindex fails with _version errorElasticsearch 重新索引失败并出现 _version 错误
【发布时间】:2018-07-10 12:22:29
【问题描述】:

我使用的是 Elasticsearch 5.5 版。

我的索引 A 带有映射:

{
  "myobj": {
    "enabled": false
}

我用映射创建了索引 B:

{
  "myobj": {
    "_all": {"enabled": false},
    "properties": {
      "mykey": {"type": "keyword"}
    }
  }
}

当我用 body 调用 reindex api 时:

{
  "source": {
    "index": "a"
  },
  "dest": {
    "index": "b"
  }
}

我收到错误:Cannot generate dynamic mappings of type [_version] for [_version]

这是我尝试过的重新索引请求正文:

{
  "source": {
    "index": "a"
  },
  "dest": {
    "index": "b",
    "version_type": "internal"
  }
}

==> Cannot generate dynamic mappings of type [_version] for [_version]


{
  "source": {
    "index": "a"
  },
  "dest": {
    "index": "b",
    "version_type": "external"
  }
}

==> Cannot generate dynamic mappings of type [_version] for [_version]


{
  "source": {
    "index": "a"
  },
  "dest": {
    "index": "b"
  },
    "script": {
      "inline": "ctx._version = ctx._source.remove(\"_version\")"
    }
}

==> [myobj][1]: version conflict, current version [-1] is different than the one provided [1507030478]


我做错了什么,如何重新索引这些文档?

编辑

此后我尝试添加 "conflicts": "proceed",这只是导致没有文档被重新索引。

我还在索引 B 的设置中添加了"index.mapper.dynamic": false,结果没有明显变化。

【问题讨论】:

  • 你试过“冲突”:“继续”,
  • 它没有帮助。

标签: elasticsearch reindex


【解决方案1】:

在 ES 中有一些“保留”字段你不能直接重新索引,例如_id_version_index。 (以及已弃用的_type

尝试在您的 reindex 中删除这些保留字段。

{
    'source': { ... },
    'dest': { ...  },
    "script": {
        'inline': 'ctx._source.remove("_id");ctx._source.remove("_version");'
    }

}

【讨论】:

    猜你喜欢
    • 2022-11-08
    • 2017-11-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-24
    • 2012-09-24
    相关资源
    最近更新 更多