Unique Documents when Emitting Several Keys

Emitting more than one key allows me to search in several values,

view.SetMap((doc, emit) => {
    emit(doc["firstName"], doc.Id);
    emit(doc["lastName"],  doc.Id);

but I now have two rows in the result set. Is there a way to filter the result set to get the unique documents?



there is no equivalent of the Distinct keyword that could do it here. So you would have to filter the answer manually. If you put all the answers in a HashSet, it will naturaly remove duplicates.

Use grouping … see the View and Query class documentation for details.