程序问答   发布时间:2022-06-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Elasticsearch Bulk API-意外的输入结束:ARRAY的预期结束标记大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决Elasticsearch Bulk API-意外的输入结束:ARRAY的预期结束标记?

开发过程中遇到Elasticsearch Bulk API-意外的输入结束:ARRAY的预期结束标记的问题如何解决?下面主要结合日常开发的经验,给出你关于Elasticsearch Bulk API-意外的输入结束:ARRAY的预期结束标记的解决方法建议,希望对你解决Elasticsearch Bulk API-意外的输入结束:ARRAY的预期结束标记有所启发或帮助;

您的格式不太正确:对于批量请求,单个项目用换行符(不是逗号)分隔,并且末尾没有方括号(即,有效负载是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"}

解决方法

我正在尝试使用localhost:9200/products/product/_bulk带有以下JSON 的POST请求批量导入:

[
  { "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","_id": 2} },{ "title": "Product B","description": "Brand B - Product B - 1 kg","price": 2.49,"sku": "wi308564","brand": "Brand B\n"},"_id": 3} },{ "title": "Product C","description": "Brand C - Product C - 2.5 kg","price": 4.49,"sku": "wi108564","brand": "Brand C\n"}
]

我不断收到以下错误:

{
"error": "JsonParseException[Unexpected end-of-input: expected close marker for ARRAY (from [Source: [B@2c1e2b0e; line: 1,column: 0])\ at [Source: [B@2c1e2b0e; line: 1,column: 3]]","status": 500
}

我尝试更改JSON格式,但没有帮助。似乎出了什么问题?

大佬总结

以上是大佬教程为你收集整理的Elasticsearch Bulk API-意外的输入结束:ARRAY的预期结束标记全部内容,希望文章能够帮你解决Elasticsearch Bulk API-意外的输入结束:ARRAY的预期结束标记所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: