Reading all documents from Couchbase server sequentially

Hi. I am creating an application which stores about 1M documents in a bucket. Once stored, I am not able to retrieve all of them. I have created a view and I have added it as a Production View. When I run my application I am always able to retrieve only 1578 documents. The size of the ViewRow is also the same. I don’t want to use N1QL.

Here is the function which is used to retrieve all the documents.

public Iterable<ViewRow> findAllUsers() {
    ViewQuery query = ViewQuery.from("dev_LCDD", "findAllUsers");
    ViewResult result = theBucket.query(query);
    return result;
 }

This function prints the size of the result which was returned by the findAllUsers() function and I am not able to get all the documents.

public List<Customer> findUserInformation() {
    Iterable<ViewRow> result = theDao.findAllUsers();
    Gson gson = new GsonBuilder().create();
    ArrayList<Customer> customers = new ArrayList<Customer>();

    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;
}

Can someone please help me with retrieving all the documents?

Hi,

you need to use “LCDD” as design document for production views. “dev_LCDD” is using the dev View.

Yes. Thanks! Problem solved!