couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Metson <si...@cloudant.com>
Subject Re: Exclude documents from view based on list of regex expressions
Date Tue, 18 Sep 2012 17:05:43 GMT
Hey Carl,
I think you'll want a map like:

function(doc) {
  var reg_exps = [/bar/g, /baz/g];
  for (r in reg_exps){
    if (doc.name.match(reg_exps[r])){
      return;
    }
  }
  emit(doc.name, 1);
}

Cheers
Simon

On Tue, Sep 18, 2012 at 5:57 PM, Carl Bourne <carl.bourne@me.com> wrote:

> Thanks for the advice Jens!
>
> I'm fairly new to Couch any chance of a simple example that shows how to
> build this type of map function?
>
> Regards,
>
> Carl
>
> Carl Bourne | Senior Sales Engineer | mobile: +44 (0) 7770 284294 |
> www.venafi.com
>
> On 18 Sep 2012, at 17:40, Jens Alfke <jens@couchbase.com> wrote:
>
> >
> > On Sep 18, 2012, at 8:51 AM, Carl Bourne <carl.bourne@me.com<mailto:
> carl.bourne@me.com>> wrote:
> >
> > Whats the best approach for excluding documents from a view based on a
> list of regex expressions. For example I want to exclude anything where
> doc.issue.name contains a value that matches a list of regex expressions.
> >
> > The map function should contain an array of regexes, and match the
> doc.issue.name against each one in turn. If it matches any of them, just
> return, else emit whatever the appropriate key/value are.
> >
> > —Jens
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message