ElasticSearch 发送数据时出错 [英] ElasticSearch error while sending data

查看:21
本文介绍了ElasticSearch 发送数据时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试向 elasticSearch 发送 JSON.我曾尝试使用 Postman 和 SOAPUI数据是

I am trying to send a JSON to elasticSearch. I have tried using Postman and SOAPUI The data is

[{"column1": "abc", "column2": "def", "column3": "dghi", "column4": "jkl", "column5": "mno"}, {"column1": "pqr", "column2": "stu", "column3": "vwx", "column4": "", "column5": ""}]

我收到以下错误

{
  "error": {
    "root_cause": [
      {
        "type": "mapper_parsing_exception",
        "reason": "failed to parse"
      }
    ],
    "type": "mapper_parsing_exception",
    "reason": "failed to parse",
    "caused_by": {
      "type": "not_x_content_exception",
      "reason": "Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes"
    }
  },
  "status": 400
}

但是当我发布一个 JSON 数组时,即

But when I post a single JSON array I.e.

{"column1": "abc", "column2": "def", "column3": "dghi", "column4": "jkl", "column5": "mno"}

然后它工作正常.我是 ElasticSearch 的新手,所以不确定出了什么问题.

Then it works fine. I am new to ElasticSearch so not sure what is going wrong.

推荐答案

先尝试使用大括号,然后命名数组.尝试一下,看看它是否有效.

Try using curly brackets first, then naming the array. Try that and see if it works.

例如:

{root:[1, 2, 3, 4, 5]}

可能有效,因为它包含在一个对象中.

might work because it's contained inside an object.

更好;当我尝试使用 JSON.stringify(); 时,我发现它可以像这样将数组转换为 JSON:

Even better; while I was experimenting with JSON.stringify();, I found that it coverts arrays to JSON like so:

{1, 2, 3, 4, 5}

这篇关于ElasticSearch 发送数据时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆