View is skipping a document

When using this view:

function (doc, meta) {
if (doc.type == “recording” && doc.company == “------”) {
for (var i=0; i<doc.events.length; i++) {
for (var j=doc.events[i].time; j< doc.events[i].duration + doc.events[i].time; j++)
{
emit(i,j)
}
}
}
}
(basically i have 39 recordings, each holding a list of events. I want the view to return events with time steps of 1 second)

It is returning events from 38 of my 39 recordings. I’ve checked events exist in the 39th, and their duration and time is fine. What is strange is that if I change the qualifier on the second ‘if’ to

j<doc.events[i].duration + doc.events[i].time - 10;

I start getting events from all 39 recordings. This doesn’t make sense to me, as it reduces the range of the query. Is there a limit on the number of results a view can return, and I happen to be right on the edge? Is this a bug?

After more testing, it seems to be related to how many results the view needs to return. If I change j++ to j+=0.5 it produces around a quarter of the results. The view is bugging out when there are too many results, but doesn’t show any kind of error.

Running Couchbase Server 4.6.1