iterview does not work for views on which you specify reduce in the options.
So since your doing a reduce there is no "id" value, and it will throw an exception. It would be nice to fix this, but I think you would have to do a skip.
Hmm, it feels like it might work with startkey, but without startkey_docid. Perhaps you can give that a whirl? The iterview() code could only pass startkey_docid if reduce is not specified, or even when id is not available on the resutl.
Specifying a startkey does not appear to help. It appears for the first batch that 'id' is available, but on the second batch (i.e. next iteration) the id is not available.
Changing client.py at line 870 from
options.update(startkey=rows[-1]['key'], startkey_docid=rows[-1]['id'])
to
try:
options.update(startkey=rows[-1]['key'], startkey_docid=rows[-1]['id'])
except KeyError:
if rows[-1]['key']!=rows[-2]['key']:
options.update(startkey=rows[-1]['key'])
else:
raise
fixed my issue, but in my specific case the key was unique because of the group level.
When doing a reduce, isn't each key unique, even for different group levels? Seems like it should be feasible to just omit the startkey_docid when reduce is True. I'm trying this out now.