How to save bulk document in Cloudant using Java or Spark - Java?

天涯浪子 提交于 2019-12-25 18:55:34

问题


Cloudant Client library available in Java that will store one document at a time,

CloudantClient client = ClientBuilder.account("accounbt")
                    .username("username").password("password")
                    .disableSSLAuthentication().build();*/

            Database db = client.database("databaseName", true);

            db.save(jsonObject);

Is there any way to save bulk document in cloudant?


回答1:


Here is the code that can enable to upload bulk upload,

CloudantClient client = ClientBuilder.account("accounbt")
                        .username("username").password("password")
                        .disableSSLAuthentication().build();*/

Database db = client.database("databaseName", true);

List<JSONObject> arrayJson = new ArrayList<String>();
arrayJson.add(new JSONObject("{data:hello}"));
arrayJson.add(new JSONObject("{data:hello1}"));
arrayJson.add(new JSONObject("{data:hello2}"));
db.bulk(arrayJson);


来源:https://stackoverflow.com/questions/40838703/how-to-save-bulk-document-in-cloudant-using-java-or-spark-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!