4.5表达式中的错误必须是组密钥或聚合

时间:2016-09-03 06:30:50

标签: database couchbase n1ql

升级到Couchbase 4.5后,我开始收到此错误“表达式必须是组密钥或汇总(writetimestamp)”,“代码”: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 }

2 个答案:

答案 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

中提到了这一点