【发布时间】:2020-05-26 18:55:59
【问题描述】:
我想将 JSON 字符串加载到 Elasticsearch 7.3 版。
以下是我为此使用的代码。
private RestHighLevelClient restHighLevelClient;
String jsonString="//here the complete JSON string";
JSONObject jsonObject = new JSONObject(cojsonStringntent1.toString());
HashMap<String, Object> hashMap = new Gson().fromJson(jsonObject.toString(), HashMap.class);
IndexRequest indexRequest = new IndexRequest("index", "type").source(hashMap);
restHighLevelClient.index(indexRequest, RequestOptions.DEFAULT);
例外: 线程“主”java.lang.NullPointerException 中的异常 在线
restHighLevelClient.index(indexRequest, RequestOptions.DEFAULT);
如果我通过 POSTMEN 发布相同的 jsonString,那么它将被完美地加载到 ELASTICSEARCH。
【问题讨论】:
-
能否提供您的 JSON 字符串和邮递员请求 JSON 以便我自己尝试?
-
似乎缺少
restHighLevelClient的初始化 -
@Lily,如果您能够解决问题,请告诉我,如果您能够解决问题,请不要犹豫,如果您能够解决问题,请投票并接受答案,以便我们了解您得到了解决方案。
-
@Lily 很长时间以来您都没有接受并支持我的答案,如果您的问题得到解决,如果您能接受并支持答案,那就太好了
标签: json elasticsearch resthighlevelclient