ElasticSearch发送数据时发生错误 [英] ElasticSearch error while sending data
问题描述
我正在尝试将JSON发送到elasticSearch。我试过使用Postman和SOAPUI
数据是
[{column1:abc,column2 :def,column3:dghi,column4:jkl,column5:mno},{column1:pqr,column2:stu,column3 :vwx,column4:,column5:}]
<我收到以下错误回来
{
pre>
error:{
root_cause:[
{
type:mapper_parsing_exception,
reason:无法解析
}
],
type
reason:无法解析,
causes_by:{
type:not_x_content_exception,
reason:Compressor detection can只能在一些xcontent字节或压缩的xcontent字节上调用
}
},
status:400
}
但是当我发布一个JSON数组时,
{column1:abc,column2:def,column3:dghi column4:jkl,column5:mno}
然后它工作正常。我是ElasticSearch的新手,所以不知道出了什么问题。
解决方案首先尝试使用大括号,然后命名数组。它被称为JSON,因为这样做,所以尝试一下,看看它是否有效。
例如:
{root:[1,2,3,4,5]}
可能会工作,因为它包含在一个对象内。
更好;当我在尝试使用
JSON.stringify();
时,我发现它将数组覆盖到JSON,如下所示:{1,2,3,4,5}
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": ""}]
I am getting the following error back
{ "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 }
But when I post a single JSON array I.e.
{"column1": "abc", "column2": "def", "column3": "dghi", "column4": "jkl", "column5": "mno"}
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. It is called JSON for a reason, so try that and see if it works.
For example:
{root:[1, 2, 3, 4, 5]}
might work because it's contained inside an object.
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屋!