Cannot access view while adding new documents to Couchbase node

Im trying out Couchbase community edition on a single node
Total ram - 24GB
Data - 7608 MB
Index - 3255 MB
Search - 576 MB

We have a total of 70k docs atm. When adding new documents via Java SDK we are unable to access Views (via paging) at the same time.

 ViewResult result =  bucket.query(ViewQuery.from(design, view)
			.key(id)
			.skip(skip)
			.limit(limit));
 List<T> ourDocs = new ArrayList<>();

result
	.iterator()
	.forEachRemaining(
			(doc) ->
					ourDocs.add(
							fromJsonObject(doc.document().content(), type))
				);

This gets executed only after we stop adding new docs.

What are you using for the “stale” parameter when querying the view?

I’ve updated my code with

       ViewResult result =  bucket.query(ViewQuery.from(design, view)
	         	.key(id)
		        .skip(skip)
		        .limit(limit)
                           .stale(Stale.TRUE));
        );

And also, Stale.UPDATE_AFTER

I still experience the same issue. View doesn’t return anything while adding docs (using C# TPL).

Hi @qubyk

You need to use Stale.FALSE to make sure all new documents are included in any view result.

A brief descrition of the Stale options:
TRUE - allow stale results, eg return what is available now
UPDATE_AFTER - return what is available now and schedule an update on the view so subsequent queries will use newer results
FALSE - schedule a view update before returning to make sure all documents are included

Couchbase Server regularly schedules view updates so results are updated periodically.

Also note that using Stale.FALSE will incur a longer time to return because it has to finish processing the view updates before returning the result.

Also, you can see more information regarding Views and it’s options for the Java SDK here: https://docs.couchbase.com/java-sdk/2.7/view-queries-with-sdk.html