У меня есть требование, при котором я должен получить документ с дивана.
Следуя функции карты, которую я использую для того же -
function (doc, meta) {
if (meta.type == "json" && doc!=null) {
emit(doc);
}
}
Функция уменьшения отсутствует. Также ниже приведен мой 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);
А данные, которые у меня есть в кушбазе, это ключ - "122" и значение - "истина". Но по какой-то причине я не получаю никаких строк в ViewResponse. Что происходит не так, кто-нибудь может помочь?