以下是弹性搜索文档提供的批量插入示例:https ://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html
POST _bulk
{ "index" : { "_index" : "test", "_type" : "type1", "_id" : "1" } }
{ "field1" : "value1" }
{ "delete" : { "_index" : "test", "_type" : "type1", "_id" : "2" } }
{ "create" : { "_index" : "test", "_type" : "type1", "_id" : "3" } }
{ "field1" : "value3" }
{ "update" : {"_id" : "1", "_type" : "type1", "_index" : "test"} }
{ "doc" : {"field2" : "value2"} }
他们提到“因为这种格式使用文字 \n 作为分隔符,请确保 JSON 操作和源没有很好地打印出来”。
我想知道这种输入格式背后的原因以及他们为什么不选择 JSON 对象数组。
例如:
POST _bulk
[{{ "index" : { "_index" : "test", "_type" : "type1", "_id" : "1" } }
{ "field1" : "value1" }},
{ "delete" : { "_index" : "test", "_type" : "type1", "_id" : "2" } }
{ "create" : { "_index" : "test", "_type" : "type1", "_id" : "3" } }
{ "field1" : "value3" }
{ "update" : {"_id" : "1", "_type" : "type1", "_index" : "test"} }
{ "doc" : {"field2" : "value2"} }]
上面的结构不正确,但类似的东西在 REST API 开发标准中我是否缺少一些常见的东西?分隔符而不是数组?