ElasticSearch批量api-输入意外结束:对象错误的预期关闭标记

axr492tv  于 2021-06-14  发布在  ElasticSearch
关注(0)|答案(1)|浏览(592)

我正在尝试将json数据上传到ElasticSearchAPI中,并尝试使用curl命令,但是当我尝试时,出现了这种错误。
错误原因

"reason": "Unexpected end-of-input: expected close marker for Object (start marker at [Source: (org.elasticsearch.common.bytes.AbstractBytesReference$MarkSupportingStreamInputWrapper); line: 1, column: 1])\n at [Source: (org.elasticsearch.common.bytes.AbstractBytesReference$MarkSupportingStreamInputWrapper); line: 2, column: 1]"

命令:

curl -XPOST -u dev-user:dev-user-password domain-endpoint/_bulk https://search-****.us-west-2.es.amazonaws.com/_bulk --data-binary @sample.json -H "Content-Type: application/json"

示例.json

{ "index": {"_index": "products", "_type": "product", "_id": 1} }
{ "title": "Product A","description": "Brand A - Product A - 1.5 kg","price": 3.49,"sku": "wi208564","supermarket": "AJ","categories": "Fruit AJ","product_type": "Sinaasappels - mandarijnen","brand": "Brand A\n"}
{ "index": {"_index": "products", "_type": "product", "_id": 2} }
{ "title": "Product B","description": "Brand B - Product B - 1 kg","price": 2.49,"sku": "wi308564","supermarket": "AJ","categories": "Fruit AJ","product_type": "Sinaasappels - mandarijnen","brand": "Brand B\n"}

我尝试了发布在这里的解决方案,elasticsearch bulk api-输入意外结束:数组应该是close标记,但仍然得到相同的错误。任何帮助都将不胜感激。

e5nqia27

e5nqia271#

在json的末尾添加了一个空行来解决这个问题。

相关问题