问题描述
存储一些文档时,它应该存储不存在,忽略其余的(应该在应用程序级完成,也许检查文档的id是否已经存在)?以下是文档中的内容:
操作类型
索引操作还接受可用于强制创建操作的op_type,允许put-if-absent行为。当使用create时,如果索引中已存在该id的文档,则索引操作将失败。
以下是使用op_type参数的示例:
$ curl -XPUT'http:// localhost:9200 / twitter / tweet / 1?op_type = create'-d'{
user:kimchy,
post_date:2009-11-15T14:12:12,
message:尝试弹性搜索
}'
另一个指定create的选项是使用以下uri:
$ curl -XPUT'http:// localhost:9200 / twitter / tweet / 1 / _create'-d'{
user:kimchy ,
post_date:2009-11-15T14:12:12,
message:尝试弹性搜索
}'
When storing some documents, it should store the nonexistent and ignore the rest (should this be done at application level, maybe checking if document's id already exists, etc.?)
Here is what is stated in documentation:
Operation Type
The index operation also accepts an op_type that can be used to force a create operation, allowing for "put-if-absent" behavior. When create is used, the index operation will fail if a document by that id already exists in the index.
Here is an example of using the op_type parameter:
$ curl -XPUT 'http://localhost:9200/twitter/tweet/1?op_type=create' -d '{
"user" : "kimchy",
"post_date" : "2009-11-15T14:12:12",
"message" : "trying out Elastic Search"
}'
Another option to specify create is to use the following uri:
$ curl -XPUT 'http://localhost:9200/twitter/tweet/1/_create' -d '{
"user" : "kimchy",
"post_date" : "2009-11-15T14:12:12",
"message" : "trying out Elastic Search"
}'
这篇关于如何检查ElasticSearch中的重复数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!