On Mon, Feb 2, 2015 at 11:45 AM, Mike Marino <[email protected]> wrote:
> > Hi,
> >
> > why do you say it is a 'mistake' to emit doc from a view?
> > I do have views that get some param and return the resulting doc(s).
> > E.g.:
> >
> > |||"|map|":|"function(doc) {if(doc.startDate && !doc.disabled)
> > {emit(doc.startDate, doc);}}"||||
> >
>
> Perhaps it's more correct to say "unnecessary". You can always get the
> associated documents from the results of a view using the include_docs
> flag. I personally don't know if this has advantages in terms of space,
> but I do believe emitting a document will result in it being saved
> additionally to disk in the view results.
>
> For your case, you can simply do
>
> emit(doc.startDate, null)
>
> and still get the behavior you need.
>
This is rather a decision between increasing the index size or making more
disk seeks to retrieve the doc. Having it in the index will be faster but
will use more storage since you duplicate the data for each emitted records.
- benoit