升级到Couchbase 4.5后,我开始收到此错误“表达式必须是组密钥或汇总(write
。timestamp
)”,“代码”:4210}。我在这里做错了什么?这是我的查询
select max(timestamp) as lastDetect, count(timestamp) as detectCount
from write
where docType is not missing AND docType = 'DetectRecord' AND proximityUUID = $uuid AND major = $major AND minor = $minor AND timestamp BETWEEN $startTime AND $endTime ORDER BY timestamp desc limit 1;
示例文件:
{
"id": "1234k",
"docType": "DetectRecord",
"proximityUUID": "12kdf",
"major": "dkf",
"minor": "ad",
"timestamp": 1464954200000
}
答案 0 :(得分:1)
这是由添加到couchbase 4.5(http://developer.couchbase.com/documentation/server/4.5/release-notes/relnotes.html)的更改引起的。将查询更改为以下内容为我解决了这个问题。
select max(timestamp) as lastDetect, count(timestamp) as detectCount
from write
where docType is not missing AND docType = 'DetectRecord' AND proximityUUID = $uuid AND major = $major AND minor = $minor AND timestamp BETWEEN $startTime AND $endTime
GROUP BY timestamp
ORDER BY timestamp desc limit 1;
答案 1 :(得分:1)
是Marquis,N1QL在4.5中强制执行正确的GROUP BY语法/语义。发行说明"行为更改":http://developer.couchbase.com/documentation/server/4.5/release-notes/relnotes.html
中提到了这一点