【问题标题】:Reading all documents from Couchbase server sequentially Couchbase Server从 Couchbase 服务器顺序读取所有文档 Couchbase 服务器
【发布时间】:2016-02-23 16:24:22
【问题描述】:

我正在创建一个在存储桶中存储大约 100 万个文档的应用程序。存储后,我无法检索所有这些。我创建了一个视图并将其添加为生产视图。当我运行我的应用程序时,我总是只能检索 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 是否仍然只访问开发视图。这是因为只有在开发视图中存在生产视图的副本时,我的应用程序才会在没有任何警告的情况下运行。我现在从开发视图中删除了副本,并且我的视图仅存在于生产视图中。我收到以下警告,“com.couchbase.client.core.endpoint.ResponseStatusConverter fromHttp 警告:HTTP 协议未知的 ResponseStatus:500"。

【问题讨论】:

  • docId 字段在哪里设置?
  • @АндрейБеньковский 在存在 findUserInformation() 的同一类中。 “if(!docId.isEmpty())”的存在与否在运行期间没有任何区别。

标签: couchbase couchbase-view


【解决方案1】:

“dev_”前缀用于开发设计文档。如果要使用已发布的视图,则需要将其删除。所以你的代码应该是

public Iterable findAllUsers() {

    ViewQuery query = ViewQuery.from("LCDD", "findAllUsers");
    ViewResult result = theBucket.query(query);
    return result;

}

【讨论】:

  • 非常感谢。它有帮助。
猜你喜欢
  • 1970-01-01
  • 2017-07-30
  • 1970-01-01
  • 1970-01-01
  • 2016-02-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多