I am using couchbase API in java
View view = client.getView("dev_1", "view1");
Query query = new Query();
query.setIncludeDocs(true);
query.setKey(this.Key);
ViewResponse res=client.query(view, query);
for(ViewRow row: res)
{
// Print out some infos about the document
a=a+" "+row.getKey()+" : "+row.getValue()+"<br/>";
}
return a;
and the java script view in couchbase
function (doc,meta) {
emit(meta.id,doc);
}
So, when I remove the statement query.setkey(this.Key) it works returns me all the tables, what am I missing here .. How can I change the function to refect only the table name mentioned in the key
Change the map function like this:
it is good practice not to emit the entire document like:
NB: This is surprisingly important:
i have tried using
setKey("key")so many times from Java projects and setting the key using CouchBase Console 3.0.1'sFilter Resultdialog, but nothing get returned.One day, i used
setInclusiveEndand it worked. i checked the setInclusiveEnd checkbox in CouchBase Console 3.0.1'sFilter Resultdialog and i got json output.i hope this will be helpful to others having the same issue. if anyone finds another way out, please feel free to add a comment about it.
i don't know why their documentation does not specify this.
EXTRA
If your json is derived from an entity class in a Java Project, make sure to include an
if statementto test the json field for the entity class name to enclose youemitstatement. This will avoid the key being emitted asnull: