簡體   English   中英

嘗試僅從Windows將大容量數據加載到ElasticSearch中的JSON編碼問題

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM