elasticsearch - 使用批量API将批处理上传到Elasticsearch存储中

标签 elasticsearch elasticsearch-bulk-api elasticsearch-bulk

我有大量的文档,它们具有相同的索引和相同的类型,但id却明显不同。我想更新现有的或批量插入新的。如何使用批量索引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"}
'

最佳答案

您需要这样做:

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

关于elasticsearch - 使用批量API将批处理上传到Elasticsearch存储中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45323691/

相关文章:

elasticsearch - 在2.x版本中嵌套CopyTo,Tokenizer和Analyzer

mysql - Elasticsearch 与 MariaDB 的数据完整性问题

java - Elasticsearch Java API 7.0 批量插入尝试基本示例,抛出错误

elasticsearch - 如何检查 ElasticSearch BulkProcessor 服务是否存在

python - 如何使用 Bulk API 通过 Python 将关键字存储在 ES 中

elasticsearch - ElasticSearch无法识别定义了编码的Context-Type header

elasticsearch - 分面搜索的后过滤器和全局聚合之间有什么区别?

.net - 使用Elasticsearch.net或PlainElastic.net批量插入Elasticsearch

elasticsearch - 上载时Elasticsearch批量插入异常