Duplicates returned in view results
I am playing around with Coucbase 2.0 using the spymemcached 2.8 preview 3 library.
Say I have created a bucket, test. I have imported 100 documents into this bucket, the general format is:
{ "_id": "foo:1", "document_type": "test", "transaction": { "id": "foo:1", "data": { "state": "OR" }, "code": "A" } }
The documents are distributed with roughly 1/3 in each code "A","B", and "C"
See the next two posts for the view and java code, I couldn't get it working in one post.
I get results like this:
29 foo:1 foo:10 foo:11 foo:12 foo:12 foo:14 foo:15 foo:17 foo:17 foo:19 foo:19 foo:2 foo:20 foo:21 foo:23 foo:23 foo:24 foo:25 foo:26 foo:26 foo:28 foo:28 foo:3 foo:4 foo:5 foo:6 foo:7 foo:8 foo:9
So, what am I missing? I am new to CouchDB, having used membase before, but I am interested in using the document store. Is this supposed to generate results like this?
and here is the java:
View view = client.getView("foo", "foo_by_code"); Query query = new Query(); query.setKey("A"); query.setIncludeDocs(false); ViewResponse response = client.query(view, query); System.out.println(response.size()); for (ViewRow viewRow : response) { System.out.println(viewRow.getId()); }
Any chance someone might have some advice on this? I've popped in the IRC channel several times and mostly met crickets in there.
It seems that we are having the same problem:
http://www.couchbase.com/forums/thread/serious-bug-view-generation
I've seen similar behaviour too.
I can also confirm similar behavior.
I am also seeing the same behavior.
http://www.couchbase.com/forums/thread/possible-ui-or-view-issue-emit-sa...
twjordan/drakmir: huge apologies for the long delay in reply.
That's certainly not expected. I don't think it's likely a client issue, but could perhaps be a cluster side issue.
Internally, the Java client is pretty simple. When it first discovers the cluster's layout, it will also get a list of URI endpoints where it may make view requests of. It is the responsibility of the cluster to get the view results from the various nodes and assemble the reply to the Java client. Missing items probably mean they were missing in the JSON response to the client.
Which version of the server are you using? Also, does it show any errors in the log?
One other thing we do is append errors to the end of the JSON view response so clients can be aware. We went back and forth and decided that should not be a cause for an exception, but rather just errors saying it completed with errors.
I've seem similar results just using your web interface (Dev-Preview 3), both in the raw JSON output and when displayed using in the interface.
I don't think there were any errors in the JSON output, but I'm not certain, and I didn't look in the error logs at the time.
I fixed the issue by editing the view (since it was only a test situation it didn't matter). Obviously in production this isn't going to be a feasible option.
Sorry I can't be more helpful.
No errors reported that I can see.
Note that my test case doesn't use the Java client, only your UI:
Set bucket up with a series of documents.
Create a view with the following map function:
function (doc) {
emit("x", null);
}
Note that the UI shows links for the first document only. Either the doc._id in the emit array is being set incorrectly or the UI is displaying the wrong link.
Note that this works (although it introduces the document id into the key):
function (doc) {
emit(["x", doc._id], null);
}
Hi twjordan / stefan / drakmir
The problem is fairly easy to reproduce on 2.0 DP3 (even without using a client SDK). We have fixed several issues with views since DP3 and this issue has also been fixed. We will be releasing DP4 very soon.
twjordan, I recreated your use case, inserted similar documents and created the same view. I could repro the issue on DP3 and verified that a DP4 candidate build fixes the issue. see query results below.
stefan, I have verified the use case you posted here: http://www.couchbase.com/forums/thread/serious-bug-view-generation works on newer builds as well. Hope you can give it a try once DP4 is out.
View: function (doc)
{ if(doc.document_type == "test") { emit(doc.transaction.code, doc.transaction); } }
On 2.0 DP3 - Query results
http://ec2-xxx-72-9-71.us-west-1.compute.amazonaws.com:8092/default/_des...
{"total_rows":25,"rows":[
{"id":"foo:1","key":"A","value":{"id":"foo:1","data":{"state":"OR"},"code":"A"}},
{"id":"foo:1","key":"A","value":{"id":"foo:3","data":{"state":"OR"},"code":"A"}},
{"id":"foo:1","key":"A","value":{"id":"foo:2","data":{"state":"OR"},"code":"A"}},
{"id":"foo:1","key":"A","value":{"id":"foo:6","data":{"state":"OR"},"code":"A"}},
{"id":"foo:1","key":"A","value":{"id":"foo:7","data":{"state":"OR"},"code":"A"}},
{"id":"foo:1","key":"A","value":{"id":"foo:5","data":{"state":"OR"},"code":"A"}},
{"id":"foo:1","key":"A","value":{"id":"foo:4","data":{"state":"OR"},"code":"A"}},
{"id":"foo:11","key":"A","value":{"id":"foo:11","data":{"state":"OR"},"code":"A"}},
{"id":"foo:11","key":"A","value":{"id":"foo:8","data":{"state":"OR"},"code":"A"}},
{"id":"foo:11","key":"A","value":{"id":"foo:9","data":{"state":"OR"},"code":"A"}},
{"id":"foo:11","key":"A","value":{"id":"foo:10","data":{"state":"OR"},"code":"A"}},
{"id":"foo:12","key":"A","value":{"id":"foo:12","data":{"state":"OR"},"code":"A"}},
{"id":"foo:15","key":"A","value":{"id":"foo:15","data":{"state":"OR"},"code":"A"}}
]}
The id's that are returned are incorrect in DP3.
On a DP4 release candidate build
http://127.0.0.1:8092/foodb/_design/dev_test/_view/test?key=%22A%22
{"total_rows":25,"rows":[
{"id":"foo:1","key":"A","value":{"id":"foo:1","data":{"state":"OR"},"code":"A"}},
{"id":"foo:10","key":"A","value":{"id":"foo:10","data":{"state":"OR"},"code":"A"}},
{"id":"foo:11","key":"A","value":{"id":"foo:11","data":{"state":"OR"},"code":"A"}},
{"id":"foo:12","key":"A","value":{"id":"foo:12","data":{"state":"OR"},"code":"A"}},
{"id":"foo:13","key":"A","value":{"id":"foo:13","data":{"state":"OR"},"code":"A"}},
{"id":"foo:14","key":"A","value":{"id":"foo:14","data":{"state":"OR"},"code":"A"}},
{"id":"foo:15","key":"A","value":{"id":"foo:15","data":{"state":"OR"},"code":"A"}},
{"id":"foo:2","key":"A","value":{"id":"foo:2","data":{"state":"OR"},"code":"A"}},
{"id":"foo:3","key":"A","value":{"id":"foo:3","data":{"state":"OR"},"code":"A"}},
{"id":"foo:4","key":"A","value":{"id":"foo:4","data":{"state":"OR"},"code":"A"}},
{"id":"foo:5","key":"A","value":{"id":"foo:5","data":{"state":"OR"},"code":"A"}},
{"id":"foo:6","key":"A","value":{"id":"foo:6","data":{"state":"OR"},"code":"A"}},
{"id":"foo:7","key":"A","value":{"id":"foo:7","data":{"state":"OR"},"code":"A"}},
{"id":"foo:8","key":"A","value":{"id":"foo:8","data":{"state":"OR"},"code":"A"}},
{"id":"foo:9","key":"A","value":{"id":"foo:9","data":{"state":"OR"},"code":"A"}}
]
}
Note that DP4 is now available. Please let us know if you see anything unexpected there.
something went wrong in that post:
here is the view: