View - map and reduce
Hi everyone!
I do not can clearly understand how I can do next functionality. I have the big view, and I need to create few reports by data of view. As I read in documentation it's possible to do with reduce() function but it's not recomentded: "not to transform the output information or concatenate the information into a single structure...". If I return all data from view and apply filtering and grouping logic in my application it's will realy slow. I read documentation again and not found way to resolve my issue. Any help?
I investigated couchbase functionality and understood that hasn't solution that can help me resolve my issues in developing web-application.
I will search other approaches to resolve my issues.
Regards, Alex
Can you share more details on what features / functionality you would have liked or you require? Can you share a little more about your application requirements?
Hi dipti.
First of all, I have many (tens-millions) same-types small documents.
I have a View that has composite key with two values - int and datetime.
This key I use to emit data by date range. This View I need use to select single or few documents, in first case, and to select by date range in second case. In second case result has >10K documents always. In this two cases all works perfectly and with unbelievable performance (very thanks for this).
But I have other cases when I need uses View mentioned above; I need generate few different reports based on data from map() function. In all this cases data will be reduced to tens-records from >10K documents.
First problem, I don't can implement needed logics in reduce() function, because it has very specific calculation that each one document depends from previous one, group value by date (without time part) and value of other field. As result of this I should have one document with result of calculation.
I have few report like this, based on one View, with different reducing. I can't create same View with little changes because it need very much spaces to build Indexes and it has impact to performance.
I understand, maybe not completely, how works Views but I can understand why impossible to use one View - many reduce() function. In most cases not enough capacity in reduce() , opportunities are very limited (add other 'function' or connect js libraries to use needed function would be grade!).
Of course I can fetch data from View in my application and calculate as I need but more time uses to cast json object to application object, and calculate them after .
I very like couchbase and I have few approaches to resolve my issues. I hope have no problem in future to implement needed abilities to my app.
Regards, Alex
not sure I understand.
You can and should use the built-in reduce functions _count, _sum, _stats. You can use group_level along with this.
some examples here: http://blog.couchbase.com/understanding-grouplevel-view-queries-compound...