Java SDK and getView() getViews()
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
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
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
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
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