我有一个普通的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
查询?