I'm starting with couchbase 3.01 and I have a question about views. The documentation I read said you should not include the full document in the index, as it will have a negative impact on both storage and performance. Now I've created a mapping function and I'm emitting null
for the document
e.g.
function(doc, meta) {
if (doc.entity && doc.entity == 'desert') {
emit(doc.type, null);
}
}
This should create an index for my various types of deserts (cookie, ice cream, cake). When I save the view, and click the 'Show Results' button in the admin console, I see all of the keys with the associated value of null
.
If I change my mapping function to include the document e.g.
function(doc, meta) {
if (doc.entity && doc.entity == 'desert') {
emit(doc.type, doc);
}
}
I get the results I expect, but, I'm concerned that this is an anti-pattern. It seems like there used to be a querystring parameter include_docs
which would dereference the document, but it doesn't appear in the documentation. Should I include the full document in the indexes I generate? If not, how do I retrieve the document by key?