gpt4 book ai didi

python - Elasticsearch计算后将两个字段回填到一个新字段中

转载 作者:太空宇宙 更新时间:2023-11-04 05:18:24 27 4
gpt4 key购买 nike

问题。我的任务是研究如何在 Elasticsearch 中回填数据。到目前为止有点空。基本要点是:

注意:所有文档都存储在每日索引下,每天约有 20 万个文档。

  • 我需要能够重新索引大约 60 天的数据。
  • 我需要为每个文档 payload.time_sec 和 payload.time_nanosec 取两个字段,取值并对它们进行一些数学计算 (time_sec * 10**9 + time_nanosec),然后将其作为单个字段返回到重新索引的文件

我正在查看带有批量助手的 Python API 文档: http://elasticsearch-py.readthedocs.io/en/master/helpers.html

但我想知道这是否可能。

我的想法是使用:批量助手拉动滚动 ID(批量更新?),遍历每个文档 ID,从每个停靠栏的两个字段中拉取数据,进行数学计算,并使用新的字段数据完成更新请求。

有人做过吗?也许是带有 groovy 脚本的东西?

谢谢!

最佳答案

Bulk helpers to pull a scroll ID (bulk _update?), iterate over each doc id, pull that data in from the two fields for each dock, do the math, and finish the update request with the new field data.

基本上,是的:

  • 使用/_search?scroll 获取文档
  • 执行您的操作
  • 发送/_bulk更新请求

其他选项是:

两者都支持脚本,如果我理解正确的话,这将是完美的选择,因为您的更新不依赖于外部因素,所以这也可以直接在服务器内完成。

关于python - Elasticsearch计算后将两个字段回填到一个新字段中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41127194/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com