【发布时间】:2014-02-08 15:42:15
【问题描述】:
我有一个要求,我从 couchbase 获取文档。
在我用于相同的 Map 函数之后 -
function (doc, meta) {
if (meta.type == "json" && doc!=null) {
emit(doc);
}
}
没有reduce函数。以下是我获取文档的 java 代码 -
List<URI> hosts = Arrays.asList(
new URI("http://<some DNS with port>/pools")
);
// Name of the Bucket to connect to
String bucket = "Test-Sessions";
// Password of the bucket (empty) string if none
String password = "";
//System.setProperty("viewmode", "development");
// Connect to the Cluster
CouchbaseClient client = new CouchbaseClient(hosts, bucket, password);
String designDoc = "sessions";
String viewName = "by_test";
View view = client.getView(designDoc, viewName);
Query query = new Query();
query.setIncludeDocs(true);
query.setKey(String.valueOf(122));
ViewResponse result = client.query(view, query);
Object object = null;
for(ViewRow row : result) {
if(null != row) {
object = row.getDocument();
}// deal with the document/data
}
System.out.println("Object" + object);
而我在 couchbase 中的数据是关键 - “122”和价值 - “真”。但由于某种原因,我在 ViewResponse 中没有得到任何行。有什么问题可以帮忙吗?
【问题讨论】: