本文介绍了如何使用Java或Spark-Java将大量文档保存在Cloudant中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Java中可用的Cloudant Client库,它将一次存储一个文档,
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);
有什么方法可以将批量文档保存在cloudant中吗?
Is there any way to save bulk document in cloudant?
推荐答案
以下是可以批量上传的代码,
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);
这篇关于如何使用Java或Spark-Java将大量文档保存在Cloudant中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!