couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Zachary Zolton <>
Subject Re: Map/Reduce Question
Date Mon, 06 Dec 2010 22:32:11 GMT

So, for instance, your view emits keys like:

["Bush", "George", "H", "W"]
["Bush", "George", "W"]
["Clinton", "William", "J"]
["Obama", "Barack", "H"]
["Reagan", "Ronald", "W"]

And you just want both rows with the last name of "Bush"?

Then you'll want to use a range query:


But, you have to URL encode the key parameter values, so it actually
ends up as this:


You can learn more about the query options here:



On Mon, Dec 6, 2010 at 4:06 PM, Matthew Woodward <> wrote:
> On Mon, Dec 6, 2010 at 1:32 PM, Matthew Woodward <>wrote:
>> Is there a way to pass a specific last name as the key in the URL and have
>> the results be the example I gave in my previous message, but only for the
>> specific last name provided as the key?
> Sorry, keep thinking of better ways to explain this.
> If I use a specific value for the regex in a match function, it works fine,
> but I'd like to use the key in the URL as the value against which to match.
> For example here's the map function:
> "map":"function(doc) {
>        var lastNameMatch = doc['lastName'].match(/Woodward/);
>        if (lastNameMatch) {
>            emit([doc.lastName, doc.firstName, doc.middleInitial], null);
>    }
> }"
> So what I'd like to be able to do is include key="Woodward" in the URL and
> have the value of the key in the URL be what's used in my match regex, or if
> there's a different way to do exact matches (because in this case I will
> always be pulling by exact key matches) and still have the rest of this work
> as described before, that's fine as well.
> --
> Matthew Woodward
> / Twitter: @mpwoodward
> Please do not send me proprietary file formats such as Word, PowerPoint,
> etc. as attachments.

View raw message