Views include expired items, even when include_docs=true is specified

I'm querying a view using the parameters:

reduce=false&stale=false&include_docs=true

However, I still get expired items with the full document included.

This has been very simple to test, by creating a new item every second with a 10 second TTL. The list in the view quickly grows, and the expiration included in the "doc" object, is quite clearly in the past.

Is there some other way to exclude expired items?

http://www.couchbase.com/docs/couchbase-manual-2.0/couchbase-views-expir...

I've already read this document, and it seems to indicate I need to specify include_docs=true, and leave out the rows with a null "doc". However, none of the "doc" objects are null.

1 Answer

« Back to question.

Hello,

Yes you may have some items in the views that are expired. If you try to get it from a Client API - using a get() - you'll see that you cannot access it.

This is due to the eventual consistency of the views. Views are based on items saved on disk. The expired items are first flagged in memory and remove lazily when accessed -get()-, and also when the disk cleanup is executed see http://www.couchbase.com/docs/couchbase-manual-2.0/couchbase-admin-cbepc... .

As is it detailed in the documentation, when the document is expired, and has been accessed once using a get, the include_docs=true, will return null in your view. (I will ask for clarification in for the documentation)

So the behavior you have is the expected one.

Regards
Tug
@tgrall

From what you're describing, if I want to use a view I have to:

1. use include_docs=true
2. leave out any items that have a null "doc" object
3. leave out any items that are past expiration (found in the meta-data)

Correct?