【问题标题】:Unexpected end-of-input: expected close marker for Array ElasticSearch意外的输入结束:Array ElasticSearch 的预期关闭标记
【发布时间】:2020-12-15 19:47:52
【问题描述】:

我正在创建对弹性搜索的批量请求,但收到标题中指定的错误 任何人都可以检查我的 JSON 可能这是不对的

{ "index" :{ "_index" : "type", "_type" : "type", "_id" : "1" }}
{"type": "Variable", "processDefinitionKey":"Variable1", "products":[
{ "index" :{ "_index" : "new_type", "_type" : "new_type", "_id" : "1" }}
{ "code": "20", "type": "Variable", "name": "Integer"}]}

【问题讨论】:

  • 第三行结尾不应该有逗号吗?
  • 您需要确保在最后一行的末尾有一个换行符。看到这个线程:stackoverflow.com/a/35845007/4604579
  • 这个建议没有帮助我解决 Unexpected end-of-input: expected close marker for Array ElasticSearch
  • @Val 我从数组中删除了所有索引,但之后我得到了其他错误格式错误的操作/元数据行 [3],应为 START_OBJECT 或 END_OBJECT,但找到了 [VALUE_STRING]

标签: java elasticsearch


【解决方案1】:

实际上,问题在于文档似乎在第 2 行和第 4 行之间拆分,并且它们都不完整

{ "index" :{ "_index" : "type", "_type" : "type", "_id" : "1" }}
{"type": "Variable", "processDefinitionKey":"Variable1", "products":[
{ "index" :{ "_index" : "new_type", "_type" : "new_type", "_id" : "1" }}
{ "code": "20", "type": "Variable", "name": "Integer"}]}

你的文档其实是这样的

{"type": "Variable", "processDefinitionKey":"Variable1", "products":[

加上这个

{ "code": "20", "type": "Variable", "name": "Integer"}]}

但它被分成两行,中间有index 命令...这不起作用。

它应该看起来像这样:

{ "index" :{ "_index" : "type", "_type" : "type", "_id" : "1" }}
{"type": "Variable", "processDefinitionKey":"Variable1", "products":[{ "code": "20", "type": "Variable", "name": "Integer"}]}
{ "index" :{ "_index" : "new_type", "_type" : "new_type", "_id" : "1" }}
{"type": "Variable", "processDefinitionKey":"Variable1", "products":[{ "code": "20", "type": "Variable", "name": "Integer"}]}

您需要确保:

  • JSON 文档位于一行(不是多行)
  • 每个 JSON 文档都有对应的命令行
  • 最后一行以换行符终止(由于 SO 格式,上面不可见)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-04
    • 2018-08-07
    • 2015-08-31
    相关资源
    最近更新 更多