On Nov 22, 2013, at 6:18 AM, John Norris <j...@norricorp.f9.co.uk> wrote:
> To continue on this path, so if I have separate document types, where > docTypeA has a reference to docTypeB, can I have a view that returns a > docTypeA based on a value within docTypeB object? I think you can do this using the linked-documents feature of the indexer. If your map function emits a value that’s an object containing a “_id” property, then the view will treat that index entry as though it were generated by the document with that ID, so if you query with include_docs the contents of the linked document will be returned. http://wiki.apache.org/couchdb/Introduction_to_CouchDB_views#Linked_documents > Also, my view returns a list of key, values. And I can use the eg key > parameter to return a particular key, value. I can also use the keys > parameter to return more than one particular key. But can I return a document > based on more than one field. Sure. In your example, the map function just has to do emit(doc.fname, null); emit(doc.lname, null); So now both the first and last names are in the index, so view queries will find both first and last names matching your key. —Jens