没有文档ID的elasticsearch upsert [英] elasticsearch upsert without document id

查看:157
本文介绍了没有文档ID的elasticsearch upsert的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我查询索引以查找文档.如果找到文档,我知道_id值要更新,否则我就没有_id值.

I query my index to find a document. If I find a document I know the _id value to update else I don't have _id value.

使用下面的upsert,我可以在有_id时进行更新.如果我没有_id,该如何提供Elasticsearch来提供_id并插入新文档?

Using the upsert below, I can update when I have _id. If I dont have _id how can I have elasticsearch to provide one and insert a new document?

目的:我不想拥有2个功能,一个功能是创建一个新文档,另一个功能是对其进行更新...

Purpose: I dont want to have 2 functions, one to create a new doc and another to update it...

curl -XPOST 'localhost:9200/test/type1/{value_of_id}/_update' -d '{
  "doc" : {
      "name" : "new_name"
  },
  "doc_as_upsert" : true

}

推荐答案

诸如通过查询更新"之类的东西?

Something like "update by query"?

在这里看到:

https://github.com/elastic/elasticsearch/issues/2230

对于原始问题/建议,进行一些有关实现的实验性工作,讨论了包括在内的优缺点,并提供了为支持该行为而开发的插件的链接.

for the original issue/proposal, some experimental work toward implementation, discussion about the pros and cons of including, and a link to the plug-in that was developed to support the behavior.

这篇关于没有文档ID的elasticsearch upsert的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆