3

I have a list of small JSON documents in the format:

{
 "name":"Kate",
 "event":"read"
},
{
 "name":"Jon",
 "event":"delete"
},...

My map function is this:

function(doc, meta){
  emit(doc.event, null);
}

As a result I get a list of all events, including duplicates. How do I reduce the resultset to distinct values only?

Thank you

2
  • Duplicate: stackoverflow.com/questions/16177986/… Commented Dec 3, 2013 at 10:42
  • No wonder I couldn't find it with a name like that :) Thanks! Commented Dec 3, 2013 at 11:15

1 Answer 1

1

This is the answer from the other question, modified to suit this question. I hope this helps someone! The reduce function:

function(keys, values, rereduce) {
  return keys.filter(function (e, i, arr) {
    return arr.lastIndexOf(e) === i;
  });
}
Sign up to request clarification or add additional context in comments.

1 Comment

if you do this you could encounter an error solved here: stackoverflow.com/questions/31152576/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.