Can i creat a view with only java code?


#1

I found this:
"To create view, you can use either the Admin Console edite,
use the REST API for design documents, or use one of the client
librarys that support view manager."
What’s the more informations about one of the client librarys that support view manager?
Is that mean i can use java code? if so, how can i use for it?


#2

May be this is a stupid topic, if so, i apologize for this…
As you can see, i am the new user of couchbase. I am curious about can i create a view with only java code?
Regards,
kenhome


#3

Yes you can, in the Java SDK 1.1.0 we have added the support to “Design Document”.
This means you can create Views from a Java application. Here s very basic sample code :

DesignDocument designDocument = new DesignDocument(“Beer_application”);
String viewName = “by_name”;
String map = “function (doc, meta) {\n” +
" emit(doc.name);\n" +
"}";
String reduce = “_count”;
ViewDesign viewDesign = new ViewDesign(viewName, map, reduce);
designDocument.getViews().add(viewDesign);
try {
couchbaseClient.asyncCreateDesignDoc(designDocument);
} catch (Exception e) {
e.printStackTrace();
}


#4

Hello,
I have created a bog post about this:
http://tugdualgrall.blogspot.fr/2012/12/couchbase-101-create-views-mapre
Regards
Tug


#5

I have been waiting for a few days,but it seems that the URL is invalid…


#6

Hello Kenhome,
Are you talking about the blog post URL?
Let’s try with this short one: http://goo.gl/FSk2K
Regards
Tug