On 14/07/2009 7:25 PM, Daniel Trümper wrote:

Can you avoid processing this field in the view?

Retrieving the view with include_docs=true can still give your users the
complete documents, but those large data would be neiter stored nor
indexed in
the view.
Jan has just given a talk in the company I work for and helped me on
this one. Of course I have been doing things wrong in general.

The specific view I was trying to generate was 'give me a set of unique
field values, when the user of my library can choose the field name'. I
did the 'uniqueness' thing in the reduce part which is, as I have now
learnt, very bad :)

A variation on your map should be able to do that.

---snip-map--
function(doc) {
  for( var field in doc ) {
    if( field.indexOf('_') != 0 ) {
      emit( field, doc[field] );
    }
  }
}
---snip-map--

If you emit([field, doc[field]], null);

(ie, make the value itself part of the key) and a simple '_sum' reduce, then querying with group=true you should get that unique list?

Mark

Reply via email to