How do I change the "stale" setting for an N1qlQuery?

I want the view to be fully indexed before results are retrieved, the equivalent of doing the following stale statement with a ViewQuery:

var q = ViewQuery.from('beer', 'by_name')
    .range(value, value + JSON.parse('"\u0FFF"'))

but for an N1qlQuery.

How do I do this with a N1qlQuery?

@neatcode from the Java SDK, there is currently no way to change the “stale” behavior for a N1QL query. This is something we will work through in the next months and for sure have a good solution once it ships together with the product.

For now you have to use the defaults that N1QL provide or fall back to Views.

@daschl OK, thanks for the quick feedback. That’s what I suspected. BTW I’m using the Node SDK so I’d like to see support for stale settings in there.

@neatcode, we have the existing flags - stale=false|after|ok in views. would it suffice for you to have those or which one would be your choice? would you want another flavor in couchbase?


I’d want the flag described in my original post as Update.BEFORE (in current Node.js SDK for ViewQuery).

This looks similar to the flag stale=false which must be in some prior or other versions/SDKs.

– Austin

thanks! would you be ok with a new level that would NOT update the indexes to the ‘time’ the was executed but to the ‘time’ that your last update happened on this connection? Essentially RYOW (read your own write)? if you have a few milliseconds between your last update and your query, this may reduce the latency of your query by quite a bit. would that be interesting in your case.
We are looking at new options and that is why I am poking at this. I’d appreciate your feedback.

1 Like