按顺序从 Couchbase 服务器读取所有文档 Couchbase Server
Reading all documents from Couchbase server sequentially Couchbase Server
我正在创建一个在存储桶中存储大约 1M 文档的应用程序。一旦存储,我将无法检索所有这些。我创建了一个视图并将其添加为生产视图。当我 运行 我的应用程序时,我总是只能检索 1578 个文档。 ViewRow 的大小也相同。我不想使用 N1QL。
这是用于检索所有文档的函数。
public Iterable findAllUsers() {
ViewQuery query = ViewQuery.from("dev_LCDD", "findAllUsers");
ViewResult result = theBucket.query(query);
return result;
}
下面给出的函数打印了 findAllUsers() 函数返回的结果的大小,但我无法获取所有文档。
public List findUserInformation() {
Iterable result = theDao.findAllUsers();
Gson gson = new GsonBuilder().create();
ArrayList customers = new ArrayList();
for (ViewRow row : result) {
Customer cust = gson.fromJson(row.document().content().toString(), Customer.class);
if(!docId.isEmpty())
customers.add(cust);
}
System.out.println("List size: "+ customers.size());
return customers;
}
有人可以帮我找回所有文件吗?
编辑:我也不确定我的 Java API 是否仍然只能访问开发视图。这是因为只有在开发视图中存在生产视图的副本时,我的应用程序 运行s 才会没有任何警告。我现在从开发视图中删除了副本,我的视图仅存在于生产视图中。我收到以下警告,“com.couchbase.client.core.endpoint.ResponseStatusConverter fromHttp
警告:协议 HTTP 的未知 ResponseStatus:500".
'dev_'前缀用于开发设计文档。如果要使用已发布的视图,则需要将其删除。所以你的代码应该是
public Iterable findAllUsers() {
ViewQuery query = ViewQuery.from("LCDD", "findAllUsers");
ViewResult result = theBucket.query(query);
return result;
}
我正在创建一个在存储桶中存储大约 1M 文档的应用程序。一旦存储,我将无法检索所有这些。我创建了一个视图并将其添加为生产视图。当我 运行 我的应用程序时,我总是只能检索 1578 个文档。 ViewRow 的大小也相同。我不想使用 N1QL。
这是用于检索所有文档的函数。
public Iterable findAllUsers() {
ViewQuery query = ViewQuery.from("dev_LCDD", "findAllUsers");
ViewResult result = theBucket.query(query);
return result;
}
下面给出的函数打印了 findAllUsers() 函数返回的结果的大小,但我无法获取所有文档。
public List findUserInformation() {
Iterable result = theDao.findAllUsers();
Gson gson = new GsonBuilder().create();
ArrayList customers = new ArrayList();
for (ViewRow row : result) {
Customer cust = gson.fromJson(row.document().content().toString(), Customer.class);
if(!docId.isEmpty())
customers.add(cust);
}
System.out.println("List size: "+ customers.size());
return customers;
}
有人可以帮我找回所有文件吗?
编辑:我也不确定我的 Java API 是否仍然只能访问开发视图。这是因为只有在开发视图中存在生产视图的副本时,我的应用程序 运行s 才会没有任何警告。我现在从开发视图中删除了副本,我的视图仅存在于生产视图中。我收到以下警告,“com.couchbase.client.core.endpoint.ResponseStatusConverter fromHttp 警告:协议 HTTP 的未知 ResponseStatus:500".
'dev_'前缀用于开发设计文档。如果要使用已发布的视图,则需要将其删除。所以你的代码应该是
public Iterable findAllUsers() {
ViewQuery query = ViewQuery.from("LCDD", "findAllUsers");
ViewResult result = theBucket.query(query);
return result;
}