You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Brian Candler <B....@pobox.com> on 2009/03/20 12:37:23 UTC

Doc missing from view

Posted to user@ because I'm almost certainly being daft, but I just can't
see what I've done wrong.

I've used CouchRest to create a test document and view. But although the
document is there, and as far as I can see it matches the criteria in the
design doc to be emitted, the view is empty.

$ curl http://127.0.0.1:5984/central-dev/_all_docs
{"total_rows":4,"offset":0,"rows":[
{"id":"02dec9f03c81fbc296a540fdf0db614c","key":"02dec9f03c81fbc296a540fdf0db614c","value":{"rev":"3-881077382"}},
{"id":"2d3e7ceca688cfd9b217a9357f6aa428","key":"2d3e7ceca688cfd9b217a9357f6aa428","value":{"rev":"3-1498780430"}},
{"id":"_design/Foo-7ff2745f17e5e9c1d537f8202791e4fd","key":"_design/Foo-7ff2745f17e5e9c1d537f8202791e4fd","value":{"rev":"1-16600353"}},
{"id":"c6093c33be207512f3274a78620e0055","key":"c6093c33be207512f3274a78620e0055","value":{"rev":"2-3661506978"}}
]}

$ curl http://127.0.0.1:5984/central-dev/02dec9f03c81fbc296a540fdf0db614c
{"_id":"02dec9f03c81fbc296a540fdf0db614c","_rev":"3-881077382","wibble":"bibble","foo":"bar","couchrest-type":"Foo"}

$ curl http://127.0.0.1:5984/central-dev/_design/Foo-7ff2745f17e5e9c1d537f8202791e4fd
{"_id":"_design/Foo-7ff2745f17e5e9c1d537f8202791e4fd","_rev":"1-16600353","language":"javascript","views":{"all":{"map":"function(doc) {\n                  if (doc['couchrest-type'] == 'Foo') {\n                    emit(null,null);\n                  }\n                }"},"by_foo_and_bar":{"map":"function(doc) {\n  if ((doc['couchrest-type'] == 'Foo') && doc['foo'] && doc['bar']) {\n    emit([doc['foo'], doc['bar']], null);\n  }\n}\n"},"by_foo":{"map":"function(doc) {\n  if ((doc['couchrest-type'] == 'Foo') && doc['foo']) {\n    emit(doc['foo'], null);\n  }\n}\n"}}}

$ curl http://127.0.0.1:5984/central-dev/_design/Foo-7ff2745f17e5e9c1d537f8202791e4fd/_view/all
{"total_rows":0,"rows":[]}
???!

$ curl http://127.0.0.1:5984/central-dev/_design/Foo-7ff2745f17e5e9c1d537f8202791e4fd/_view/by_foo
{"total_rows":0,"rows":[]}
???!

This is with CouchDB r755146 compiled a couple of days ago.

Regards,

Brian.

Re: Doc missing from view

Posted by Brian Candler <B....@pobox.com>.
After going through my session transcripts I'm now able to replicate this
reliably, and it looks to me very much like a couchdb problem.

I replicated it first using Ruby/CouchRest, and then as a pure shell script.
Both are attached.

When I run this, I see the output of the "all" and "by_foo" views are empty.
However if I comment out one of the document updates, so that the second one
doesn't fail with a conflict, then the view works just fine.

So somehow, a document update which was rejected due to an incorrect _rev
has caused the entire document to become invisible to the view.

Regards,

Brian.