I have a plain select
query for which mapreduce
view is already present.
Query:
select count(*) from my-bucket where type = 'Order' and status = 'CREATED' and timestamp > MILLIS("2016-05-15T03:59:00Z") and timestamp <= MILLIS("2017-05-15T03:59:00Z")
view:
function (doc, meta) {
if (doc._class == "com.myclass.Order"){
emit([doc.type,doc.status, doc.timestamp], null);
}
}
query:
Start key : ["Order","CREATED",1535605294320] End key : ["Order","CREATED",1535605594320]
Requirement: Now, we would want this view to support a query having “IN” clause on “status” parameter. Also, we would like to add additional parameters supporting “IN” parameters. Sample N1Ql would be like below.
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")
How to write a query on view to accomplish this? Only solution comes to my mind is to fire multiple (lets says x) queries on views
where x = m1*m2*....*mn m1=number of paremeters in first IN clause n=number of IN clauses.
Is there any better solution like executing this query in batch or a single mapreduce
query?