Hello I have a data set with the next documents in the bucket
{visitiorId: 123456, status: 2}
{visitorId: 123456, status: 2}
I would like to this set to be grouped by visitorId thus only giving one object as the result.
{visitorId: 123456, status: 2}
can somebody point me in the right direction? I seem to have trouble translating the group by clause from sql to map/reduce function.
You can write view like this
Then query liks this
Doing it like will give the total count of documents with the key [123456,2], what I am looking for is a result that will look like.
{visitorId: 123456, status: 2}
I do not wish to get the count, I want a reduced set that does not have duplicated.
If you just want to use map/reduce function to group by columns,you have to write reduce function which use the" _count"、 “_sum” or “ _stats".N1ql is easy to do this like :
“select visitiorId,status from bucket group by visitiorId,status”