Hzzl
1
Hi all,
after creating a view with a combined key
function (doc, meta)
{
emit([doc.code, doc.year, doc.month, doc.day], some_value_to_be_summed);
}
and I’ve sent it to production after testing. The combined key can be used for grouping, e.g. summing per code per year, or per month.
My question: Having done this for the ACCOUNTS bucket, how can I get all values for code A1234 for year 2012 using N1QL or Linq?
Thanx for your help!
vsr1
2
N1QL (Will not use map-reduce view) directly uses bucket data, Checkout https://blog.couchbase.com/comparing-couchbase-views-couchbase-n1ql-indexing/
SELECT d.month, d.day, SUM(d. some_value_to_be_summed) AS s
FROM default AS d
WHERE d.code = "A1234" AND d.year = 2012
GROUP BY d.month, d.day
Hzzl
3
Ow OK. So I do not gain anything with a view when using N1QL? Is that right? If so, when IS the map-reduce view used?
vsr1
4
Map reduce views can be used with curl or API’s in SDK directly.
Hzzl
5