Is there a way to filter before reduce when using view?


#1

order of view query is map~reduce~sort~selection~.
is there a way filtering data before reduce?


#2

Assuming you’re talking about Couchbase Server’s views, the only direct way to filter is in the map() function. Couchbase’s views (unlike Hadoop M-R) are always queried pre-built, so there is no opportunity to filter.

One technique that may work, depending on your use case, is to filter at the time of query by having compound keys in your reduction. You may want to read up on this in the docs or if you give a bit more detail about what you’re trying to achieve, either @vmx or I may be able to guide you.


#3

let a, b, c is key field.
c is date type.
i wanna filter date and reduce by group_level=2.
is it possible with views?


#4

Not exclusively, no. I have an app where I do something similar. I just query the view for each range, so I end up querying the same view several hundred times. That actually works quite well in my particular app.