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

Java SDK and getView() getViews()

4 replies [Last post]
  • Login or register to post comments
Sun, 01/27/2013 - 08:10
TimMeade
Offline
Joined: 01/27/2013
Groups: None

I am very new to couchbase 2.0 but also very impressed so far.

I am using ColdFusion (railo actually) with the JAVA SDK and have had great results so far.

myClient.set() and myClient.get() is working very well, so I'm sure I've gotten the client handle properly.

In the myClient exposed methods I can see getView() and getViews().

When I try to invoke them, I get nothing in return. No errors and certainly no data or lists of views.

Is there a simple explanation I may be missing?

Thanks

Tim

Top
  • Login or register to post comments
Mon, 01/28/2013 - 03:55
tgrall
Offline
Joined: 09/05/2012
Groups: None

Hello Tim,

If I am correct the getView() and getViews() methods are not coming from the same class:
- CouchbaseClient:
http://www.couchbase.com/autodocs/couchbase-java-client-1.1.0/com/couchbase/client/CouchbaseClient.html#getView(java.lang.String, java.lang.String)

- DesignDocument:
http://www.couchbase.com/autodocs/couchbase-java-client-1.1.0/com/couchbase/client/protocol/views/DesignDocument.html#getViews()

In the case of CouchbaseClient you use the getView("design", "View") to execute a query. You are using the getViews() from DesignDocument when you are working with the 'source' of the view itself.

Take a look to this blog post that should help you:
http://tugdualgrall.blogspot.fr/2012/12/couchbase-101-create-views-mapre...

Let me know if you have more question

Regards

__________________

Tug
@tgrall

Top
  • Login or register to post comments
Mon, 01/28/2013 - 12:55
TimMeade
Offline
Joined: 01/27/2013
Groups: None

The view is already designed and works via http.

I was trying to set it up so that I can run the query via the client.

I can see the getView and getViews methods, but they return nothing when I invoke them.

Thanks

Top
  • Login or register to post comments
Tue, 02/12/2013 - 08:09
tgrall
Offline
Joined: 09/05/2012
Groups: None

Hello,

Take a look to this sample code:
https://github.com/couchbaselabs/DeveloperDay/blob/master/Java/basic-ope...

                View view = cb.getView("brewery", "by_name");
                Query query = new Query();
                query.setLimit(10);
 
                ViewResponse viewResponse = cb.query(view, query);
                for (ViewRow row : viewResponse) {
                    System.out.println(row.getKey());
                }

You should use the client.getView()

I am surprised that you see a getViews() in your client API, the only place I see a getViews is part of the designDocument API

Regards

__________________

Tug
@tgrall

Top
  • Login or register to post comments
Tue, 02/12/2013 - 13:14
shahshi15
Offline
Joined: 02/11/2013
Groups: None

Tim,

Just my 2 cents here. I have been reading a lot on the .set/.add/.get methods of this SDK and how it behaves with views, and this is what my conclusion is (and you'd probably give me feedback on what you think as well).

The get/set works async as designed. But for the document that you added/set as a part of the .add/.set needs to be ACTUALLY persisted to the disk in order for the view queries to pick it up. Now, being an async call, you are never certain when the document does get persist to disk (and THUS ready for query and indexing through views) unless you actually "observe" the .add/.set operation itself.

Now, I am totally going to start taking a guess here.

In order to "observe" the .add/.set (I think of this "observe" notion as making a sync call while it persists to the disk itself), you use the .add (String key, expireTime, value, PersistTO.MASTER) API.

the API documents that this operation will "observe" till the time the document actually gets persisted to the disk (and thus ready for view queries).

In theory, this API should just work fine. Although, I am running into some issues with this API (ArrayOutOfBounds. Already started another thread for that).

In short, I am guessing your views are not able get the data because the data is actually not persisted to the disk itself.

PS: I could be totally wrong about this whole assumption :-). I just started developing and using this SDK last night :).

I hope we can get some expert opinion here.

Cheers,
Shivang

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