我有一个简单的select
查询,哪个mapreduce
视图已经存在。
询问:
select count(*) from `my-bucket` where type = 'Order' and status = 'CREATED' and timestamp > 1535605294320 and timestamp <= 1535605594320
看法:
function (doc, meta) {
if (doc._class == "com.myclass.Order"){
emit([doc.type,doc.status, doc.timestamp], null);
}
}
查询视图的键:
Start key : ["Order","CREATED",1535605294320]
End key : ["Order","CREATED",1535605594320]
要求:现在,我们希望此视图支持具有参数IN
子句的查询status
。此外,我们想添加额外的参数支持IN
参数。示例N1Ql
如下。
select count(*) from `my-bucket` where type = 'Order' and orderType IN ["TYPE-A","TYPE-B","TYPE-C"]and status IN ['CREATED',""READY,"CANCELLED"] and timestamp > MILLIS("2016-05-15T03:59:00Z") and timestamp <= MILLIS("2017-05-15T03:59:00Z")
如何在视图上编写查询来完成此操作?我想到的唯一解决方案是在视图上触发多个(比如说 x)查询
where x = m1*m2*....*mn
AND m1=number of paremeters in first IN clause
AND n=number of IN clauses.
有没有更好的解决方案,例如批量执行此查询(使用java
SDK)或单个mapreduce
查询?