我使用Spark将大量数据写入Elasticsearch。但它们中的一些(有时大多数)是在此上下文中具有相同id的重复文档。由于将数据写入ES需要花费很多时间,我想知道如果文档的id已经存在于ES中,如何跳过索引?
像这样:
if doc.id in ES:
continue
else
doc.index(ES)
发布于 2017-02-21 11:55:54
我不知道spark是如何工作的,但在es中你可以设置operation type。
PUT twitter/tweet/1?op_type=create
{
"user" : "kimchy",
"post_date" : "2009-11-15T14:12:12",
"message" : "trying out Elasticsearch"
}
但唯一的问题是
When create is used, the index operation will fail if a document by that id already exists in the index.
https://stackoverflow.com/questions/42358338
复制相似问题