简体   繁体   English

在 Elasticsearch 的 update_by_query api 中获取更新的文档 ID

[英]get updated doc ids in Elasticsearch's update_by_query api

I use the following query to update some weight filed in matched docs.我使用以下查询来更新匹配文档中的一些权重。 I need to get the list of updated docs id but I don't know how to do that?我需要获取更新的文档 ID 列表,但我不知道该怎么做?

    POST v1_shingle_analyzer/_update_by_query
{
    "script" : {
        "source": "ctx._source.content_completion.weight ++",
        "lang": "painless",
        "_source":true,
        "_source_includes":"_id"
    
    },
    "query": {
    "ids": {
      "values": ["ad22784cde0cecab176811ca9d77e7c2","dssdg784cde0cecab176811ca9fgdfg"]
     
    }
  }
}

References this , this legend answer , this plugin and few ES forum posts, JIRAs.参考这个这个传说的答案这个插件和一些 ES 论坛帖子,JIRA。

Short answer:简短的回答:

There is no direct way of doing this.没有直接的方法可以做到这一点。 You may need to query again with the IDs to check whether it changed.您可能需要再次查询IDs以检查它是否已更改。

Detailed answer:详细解答:

As per the documentation , Response doesn't have a field to return the updated IDs .根据文档, Response 没有返回更新后的IDs的字段。

The plugin mentioned is deprecated/dropped the support to context as per the GitHub link.根据GitHub链接,提到的插件已弃用/放弃对上下文的支持。 But I think that但我认为

  1. you can look at the source code to figure out a way to get the IDs updated If it really matters.如果真的很重要,您可以查看源代码以找出更新IDs的方法。
  2. I see here that there is a response option.在这里看到有一个响应选项。 We can set three values.我们可以设置三个值。 But it doesn't say anything about returning IDs.但它没有说明返回 ID。 It says options related to which shard, what type is updated, etc.. You can look at this if there is anyway to tweak this.它说与哪个分片、更新什么类型等相关的选项。如果有任何调整的话,你可以看看这个。

Kindly let me know for more information.请让我知道更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM