我需要在查询中使用where子句来过滤掉小于作为参数传递的一周的记录。
Java代码(N1QL查询):
statement = select("distinct Week, Season")
.from(i(bucketName.toString())).where((x("meta().id").like(s("TescoWeek%"))))
.orderBy(Sort.asc("Week"));
return couchBaseRepository.getQueryResultAsString(cluster, bucketName, statement);
我想从“周”字段中仅获取大于“201526”的记录。
Couchbase Doc样本是:
{
"id": "SS16-201525",
"type": "TescoWeeks",
"Season": "SS16",
"Week": "201525"
}
谢谢, IRK
答案 0 :(得分:1)
添加以下查询并获得我的预期结果。
statement = select("distinct id, Season, Week")
.from(i(bucketName.toString())).where(x("Season").eq(s(seasonId)).and(x("meta().id").like(s("TescoWeek%"))
.and(x("Week").gte(s(startWeek)))))
.orderBy(Sort.asc("Week"));
System.out.println(statement.toString());
return couchBaseRepository.getQueryResultAsString(cluster, bucketName, statement);