0

First time posting on StackOverflow, so bear with me....

I have a JSON document that contains LastName, FirstName, SSN (encrypted), Address, Phone. The application allows the User to search based on LastName/FirstName OR SSN OR Address OR Phone. Is there a way to create a single view in CouchDB that will handle all of the conditions or do I need to write a separate view for each one? Suggestions on the most efficient way to handle this?

I was hoping that I could write a single view and be able to manipulate the startkey and endkey to get the desired result but I haven't had any luck getting it to work.

1 Answers1

3

This will give you a key for each of the attributes of the document when finding results you can reference the documents via the doc._id.

function(doc){
    emit(doc.firstName, null);
    emit(doc.lastName, null);
    emit(doc.sSN, null);
} 
Hans
  • 2,800
  • 3
  • 28
  • 40