[英]Attempting to use JQ to process json data : Elasticsearch bulk index api
[英]JSON encoding issue attempting to load bulk data into ElasticSearch, only from Windows
我正在将文件上传到ElasticSearch /_bulk
api以插入/更新记录。 在我的本地计算机(OSX)上,我没有遇到任何问题,并且继续能够毫无问题地发送“问题”数据。
从运行Windows Server 2012的QA服务器中,ES对于包含带有变音符号(重音)的名称的行返回错误。
数据与此类似(更改了名称但留下了重音符号): María
返回的错误是:
MapperParsingException [无法解析[name.display]]; 嵌套:JsonParseException [无效的UTF-8中间字节0x61,位于[来源:[B @ 466e94e8; 行:1,列:194]]];
基于其他一些堆栈溢出答案 ,我目前认为这是某种编码问题。
我正在使用Adobe ColdFusion 11通过以下代码上传文件:
cfhttp( method=arguments.method, url=arguments.uri, result="result" ) {
cfhttpparam( type="body", value="#fileReadBinary( file )#" );
}
由于我怀疑存在编码问题,因此我还添加了一个标头,以尝试将其编码为UTF-8
,如下所示:
cfhttp( method=arguments.method, url=arguments.uri, result="result" ) {
cfhttpparam( type="header", name="Content-Type", value="application/javascript; charset=UTF-8" );
cfhttpparam( type="body", value="#fileReadBinary( file )#" );
}
无论我尝试什么,我都会继续收到相同的错误消息。 我不确定从这里去哪里。
经过足够的整理后,我记得函数charsetEncode()
可能有用。
我在Windows和OSX上都对此进行了测试,以确保Windows修复程序不会破坏OSX上的功能,并且到目前为止,它在两个位置都可以正常使用:
cfhttp( method=arguments.method, url=arguments.uri, result="result" ) {
cfhttpparam( type="header", name="Content-Type", value="application/javascript; charset=UTF-8" );
cfhttpparam( type="body", value="#charsetEncode(fileReadBinary( file ), 'utf-8')#" );
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.