我知道有一种方法可以使用 Couchbase java sdk 访问缩减的视图结果。我目前无法做的是使用 spring-data 来访问缩减视图。这可能吗?
看法:
View byIdGetDateStats = DefaultView.create("byIdGetDateStats",
"function (doc, meta) {"
+ "if(doc.docType == \"com.bd.idm.model.DayLog\"){"
+ " emit(doc.userid, doc.date)"
+" }}"
,"_stats"
);
当我尝试使用 spring-data 访问这样的视图时:
Query query = new Query();
query.setKey(ComplexKey.of(userid)).setReduce(true).setGroup(true);
ViewResult result = repo.findByIdGetDateStats(query);
错误信息
java.lang.IllegalStateException: Failed to execute CommandLineRunner
...
Caused by: java.lang.RuntimeException: Failed to access the view
...
Caused by: java.util.concurrent.ExecutionException: OperationException: SERVER: query_parse_error Reason: Invalid URL parameter 'group' or 'group_level' for non-reduce view.
....
Caused by: com.couchbase.client.protocol.views.ViewException: query_parse_error Reason: Invalid URL parameter 'group' or 'group_level' for non-reduce view.
……