1
votes

I'm using Couchbase to power the back end of my mobile app and am experiencing a strange error when using views.

I have a view set up to fetch a specific document type and am querying that view via the Sync-Gateway admin API. Normally it works well but I've found that if a document has been recently added to the database then the view query will return 0 results on the first request. The second identical request will then return the expected response.

I suspect that the new document hasn't been indexed by couchbase yet and the query triggers a re-indexing of documents. What I'm wondering is if there's a way of notifying couchbase that I'm about to query the view and to prepare the documents in advance. I don't want to have to perform 2 requests for each query.

Has anyone else come across this issue?

Any solutions?

1
What versions of Sync Gateway and Couchbase Server are you running? How are you creating the new document?Hod
Sync-Gateway is 1.5.1-community. Couchbase Server is latest so 5.1. New document is created from a custom API that uses the admin API over port 4985Rob Sanders

1 Answers

2
votes

By default, Sync Gateway allows using a "stale" index, meaning a query won't necessarily rebuild the index before processing a query.

To override this, add stale=false to your query.

(Allowed options are false, ok, and update_after. The default is update_after.)