Mathew,
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:
startkey=["Bush"]&endkey=["Bush",{}]
But, you have to URL encode the key parameter values, so it actually
ends up as this:
startkey=%5B%22Bush%22%5D&endkey=%5B%22Bush%22%2C%7B%7D%5D
You can learn more about the query options here:
http://wiki.apache.org/couchdb/HTTP_view_API#Querying_Options
Cheers,
Zach
On Mon, Dec 6, 2010 at 4:06 PM, Matthew Woodward <matt@mattwoodward.com> wrote:
> On Mon, Dec 6, 2010 at 1:32 PM, Matthew Woodward <matt@mattwoodward.com>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
> matt@mattwoodward.com
> http://blog.mattwoodward.com
> identi.ca / Twitter: @mpwoodward
>
> Please do not send me proprietary file formats such as Word, PowerPoint,
> etc. as attachments.
> http://www.gnu.org/philosophy/no-word-attachments.html
>
|