I want to make bulk insert in java with http post to Elasticsearch server. I initiate org.json.JSONObject from the json string, up to now everything is normal. However when I execute the post method, Elasticsearch return me that error:
MapperParsingException[failed to parse [replyContent.value]];nested: JsonParseException[Invalid UTF-8 middle byte
The string contains turkish characters such as: ü, ç, ş...
I tried this code:
JSONObject jObject=new JSONObject(new String(jsonString.toString().getBytes("ISO8859_9"), "UTF8"));
With this initialization, post has been worked, nevertheless, this time all the turkish characters were converted to ? character.
What could be the solution code for this problem, and where should it be? In initiation code of json object or when I post the json data?
Thanks
String sb= new SearchService().execute("item", dateFormat.format(date)); JSONObject jo=new JSONObject(new String(sb.getBytes("ISO8859_1"), "UTF8"));Then when I post the json, I convert it back to string again with the method toStringstrBuffer.append(bindings.getJSONObject(i).toString() + "\n");