Couchbase
  • Why NoSQL?
  • Couchbase Server
  • Download
  • Resources
  • Careers
Home | Forums | Couchbase | Couchbase Server 2.0

Duplicates returned in view results

12 replies [Last post]
  • Login or register to post comments
Sun, 01/29/2012 - 17:45
twjordan
Offline
Joined: 01/29/2012
Groups:

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?

Top
  • Login or register to post comments
Sun, 01/29/2012 - 17:47
twjordan
Offline
Joined: 01/29/2012
Groups:

something went wrong in that post:

here is the view:

function (doc) {
  if(doc.document_type == "test") {
  	emit(doc.transaction.code, doc.transaction);
  }
}

Top
  • Login or register to post comments
Sun, 01/29/2012 - 17:48
twjordan
Offline
Joined: 01/29/2012
Groups:

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());
		}

Top
  • Login or register to post comments
Thu, 02/02/2012 - 10:54
twjordan
Offline
Joined: 01/29/2012
Groups:

Any chance someone might have some advice on this? I've popped in the IRC channel several times and mostly met crickets in there.

Top
  • Login or register to post comments
Thu, 02/02/2012 - 11:15
stefan
Offline
Joined: 02/01/2012
Groups: None

It seems that we are having the same problem:

http://www.couchbase.com/forums/thread/serious-bug-view-generation

Top
  • Login or register to post comments
Thu, 02/02/2012 - 22:04
Eugaia
Offline
Joined: 10/11/2010
Groups: None

I've seen similar behaviour too.

Top
  • Login or register to post comments
Fri, 02/03/2012 - 05:15
cjo
Offline
Joined: 02/02/2012
Groups: None

I can also confirm similar behavior.

Top
  • Login or register to post comments
Fri, 02/24/2012 - 18:23
drakmir
Offline
Joined: 01/07/2012
Groups: None

I am also seeing the same behavior.

http://www.couchbase.com/forums/thread/possible-ui-or-view-issue-emit-sa...

Top
  • Login or register to post comments
Tue, 03/06/2012 - 10:33
ingenthr
Offline
Joined: 03/16/2010
Groups:

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.

Top
  • Login or register to post comments
Tue, 03/06/2012 - 12:59
Eugaia
Offline
Joined: 10/11/2010
Groups: None

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.

Top
  • Login or register to post comments
Wed, 03/07/2012 - 00:30
drakmir
Offline
Joined: 01/07/2012
Groups: None

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);
}

Top
  • Login or register to post comments
Wed, 03/07/2012 - 04:09
dipti
Offline
Joined: 11/02/2011
Groups:

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"}}
]
}

 

Top
  • Login or register to post comments
Fri, 03/23/2012 - 13:29
ingenthr
Offline
Joined: 03/16/2010
Groups:

Note that DP4 is now available. Please let us know if you see anything unexpected there.

Top
  • Login or register to post comments
  • Login or register to post comments
  • Login
  • Register

Company

  • About Us
  • Leadership
  • Customers
  • Partners
  • Contact Us

Product

  • Couchbase Server
  • Couchbase SDKs
  • Use Cases
  • Documentation
  • Forums

Open Source

  • Couchbase Project
  • Couchbase vs. CouchDB

Commercial

  • Subscriptions & Support
  • Training & Services

News

  • Blog
  • Newsletter
  • Press Releases
  • Buzz

Follow Us

    
  • Customer Login
  • Terms of Service
  • Privacy Policy
  • Trademark Policy
  • Site Map

© 2013 COUCHBASE All rights reserved.

Sign in to Couchbase Community

close
  • Create new account
  • Request new password
You are logging into the Forums, Wiki and Issue Tracker