我有一个巨大的文档集合,具有相同的索引和相同的类型,但明显不同的ids。我想要更新现有的或批量插入新的。我如何使用批量索引API来实现它?我想做类似下面的事情,但它抛出了错误。基本上,我想批量插入多个具有相同索引和相同类型的文档。
curl -s -H "Content-Type: application/json" -XPOST localhost:9200/_bulk -d'
{ "index": {"_type": "sometype", "_index": "someindex"}}
{ "_id": "existing_id", "field1": "test1"}
{ "_id": "existing_id2", "field2": "test2"}
'
发布于 2017-07-26 18:52:53
你需要这样做:
curl -s -H "Content-Type: application/json" -XPOST localhost:9200/someindex/sometype/_bulk -d'
{ "index": {"_id": "existing_id"}}
{ "field1": "test1"}
{ "index": {"_id": "existing_id2"}}
{ "field2": "test2"}
'
因为所有文档都在相同的索引/类型中,所以将其移动到URL中,并且只为您想要批量更新的每个文档指定_id
。
https://stackoverflow.com/questions/45323691
复制相似问题