这是我存储在桶中的文档。Id(key)属性也是screenName。
{
"created": null,
"createdBy": null,
"updated": null,
"updatedBy": null,
"screenName": "steelers",
"appId": "100",
"domain": "100$APPINFOTEAM",
"alias": "steelers",
"devision": "1"
}
我在Couchbase中有多个这种格式的文档。所以我需要按降序获取这些文档。这就是我使用它的实现,
Query query = new Query();
// Filter on the domain key
query.setIncludeDocs(true);
query.setDescending(true);
query.setInclusiveEnd(true);
query.setKey(domain);
List<AppInfoTeam> appInfoTeam = appinfoTeamService.getAppInfoTeamForApp(query);
这将给我准确的文档,而不需要排序。这是我的视图
function (doc, meta) {
if (doc._class == "com.link.twitter.pojo.AppInfoTeam") {
emit(doc.domain, null);
}
}
我还尝试使用Couchbase服务器接口过滤结果。我在降序和包含的_end值上打勾。也把域作为键。然后,当我点击显示结果按钮时,它会给我这个错误。
url: ?stale=false&descending=true&inclusive_end=true&key=domain&connection_timeout=60000&limit=10&skip=0
错误:{"error":"bad_request","reason":"invalid UTF-8 JSON: {{error,{1,"lexical error: invalid char in json text.\n"}},n "domain"}"}
如何解决这个问题?
你需要用双引号把关键字括起来:
<url>?stale=false&descending=true&inclusive_end=true&key="domain"&connection_timeout=60000&limit=10&skip=0