My document is like this:
{
id: ‘ABC123’,
background: ‘red’,
foreground: ‘black’,
border: ‘black’
}
I need to be able to find documents by color. So, I create this view:
function (doc, meta) { emit(doc.background, null); emit(doc.foreground, null); emit(doc.border, null); }
The index now becomes:
‘red’ - ‘ABC123’
‘black’ - ‘ABC123’
‘black’ - ‘ABC123’
If I search the index by key ‘black’, I get the same document twice. This is completely unhelpful. How to make sure that the same key and document ID is added only once to the index? More importantly, how do I solve my use case? Thanks.