You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Timothy Baldridge <tb...@gmail.com> on 2009/12/08 19:58:27 UTC
Duplicate keys in a view
I've been working with CouchDB for several weeks now, and love it, but
I've got a bug that's giving me issues.
I have a map function in a View that generates many duplicate keys.
Let's say these keys are thus:
[ "foo", "bar"],
[ "foo", "barr"],
[ "foo", "bar"],
Now I want to query the two duplicate rows above. However here's where
I hit an issue. If I use: ?key="['foo', 'bar']"
Couchdb replies:
{"total_rows":3,"offset":0,"rows":[]}
I assume this is because we have duplicate keys. However, if I do this:
?start_key="['foo', 'bar']"&end_key="['foo', 'bar']"
I get all three docs returned (instead of the two I wanted), because
barr is considered a subset of bar.
So how do I get the view to return multiple rows?
Thanks.
Timothy Baldridge
Re: Duplicate keys in a view
Posted by Paul Davis <pa...@gmail.com>.
On Tue, Dec 8, 2009 at 2:11 PM, Timothy Baldridge <tb...@gmail.com> wrote:
> You're right...that fixed it.
>
> It seems to be that I just simply "FAIL" when it comes to JSON. I had
> assumed that in JSON (like in JavaScript) " == ' . This is not the
> case. As you'll notice above I have single quotes around the values,
> this forced me to use double quotes around the key definition so that
> it'd be accepted by CouchDB. This was causing the issue, I switched to
> double quotes and dropped the quotes on the outside of the key and it
> works fine.
>
> Thanks!
>
> Timothy
>
If you were submitting this with cURL its easy to run afoul of the
shell escaping semantics. I tend to single quote the entire URL to
account for the JSON as well as ampersands in the query string.
HTH,
Paul Davis
Re: Duplicate keys in a view
Posted by Timothy Baldridge <tb...@gmail.com>.
You're right...that fixed it.
It seems to be that I just simply "FAIL" when it comes to JSON. I had
assumed that in JSON (like in JavaScript) " == ' . This is not the
case. As you'll notice above I have single quotes around the values,
this forced me to use double quotes around the key definition so that
it'd be accepted by CouchDB. This was causing the issue, I switched to
double quotes and dropped the quotes on the outside of the key and it
works fine.
Thanks!
Timothy
Re: Duplicate keys in a view
Posted by Alex P <ap...@kolosy.com>.
that's pretty odd, the first request should do what you need. it might be
the quotes around the array, if that's how you're submitting it.
On Tue, Dec 8, 2009 at 1:00 PM, Timothy Baldridge <tb...@gmail.com>wrote:
> I've been working with CouchDB for several weeks now, and love it, but
> I've got a bug that's giving me issues.
>
> I have a map function in a View that generates many duplicate keys.
> Let's say these keys are thus:
>
> [ "foo", "bar"],
> [ "foo", "barr"],
> [ "foo", "bar"],
>
> Now I want to query the two duplicate rows above. However here's where
> I hit an issue. If I use: ?key="['foo', 'bar']"
>
> Couchdb replies:
>
> {"total_rows":3,"offset":0,"rows":[]}
>
> I assume this is because we have duplicate keys. However, if I do this:
>
> ?start_key="['foo', 'bar']"&end_key="['foo', 'bar']"
>
> I get all three docs returned (instead of the two I wanted), because
> barr is considered a subset of bar.
>
> So how do I get the view to return multiple rows?
>
> Thanks.
>
> Timothy Baldridge
>
>
>
>
> --
> “One of the main causes of the fall of the Roman Empire was
> that–lacking zero–they had no way to indicate successful termination
> of their C programs.”
> (Robert Firth)
>
Duplicate keys in a view
Posted by Timothy Baldridge <tb...@gmail.com>.
I've been working with CouchDB for several weeks now, and love it, but
I've got a bug that's giving me issues.
I have a map function in a View that generates many duplicate keys.
Let's say these keys are thus:
[ "foo", "bar"],
[ "foo", "barr"],
[ "foo", "bar"],
Now I want to query the two duplicate rows above. However here's where
I hit an issue. If I use: ?key="['foo', 'bar']"
Couchdb replies:
{"total_rows":3,"offset":0,"rows":[]}
I assume this is because we have duplicate keys. However, if I do this:
?start_key="['foo', 'bar']"&end_key="['foo', 'bar']"
I get all three docs returned (instead of the two I wanted), because
barr is considered a subset of bar.
So how do I get the view to return multiple rows?
Thanks.
Timothy Baldridge
--
“One of the main causes of the fall of the Roman Empire was
that–lacking zero–they had no way to indicate successful termination
of their C programs.”
(Robert Firth)