You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Danny Brain <te...@gmail.com> on 2010/09/28 02:50:34 UTC

Views with composite keys inclusive_end not functioning correctly

Hello,

I'm having an issue where views with composite keys are not inclusive of the
endkey, even with inclusive_end specified as true.
This is preventing me from correctly selecting a group of documents as per
the "Linked documents" section on the Http view API wiki page (
http://wiki.apache.org/couchdb/Introduction_to_CouchDB_views)

I'm running CouchDb 1.0.1. Example of the issue I'm seeing:

composite_key_view?startkey=["AA"]&inclusive_end=true
{"id":"1","key":["AA",0],"value":null},
{"id":"1","key":["AA",1],"value":{"_id":"4"}},
{"id":"2","key":["BB",0],"value":null}

composite_key_view?startkey=["AA"]&endkey=["AA"]&inclusive_end=true
No results

composite_key_view?startkey=["AA"]&endkey=["BB"]&inclusive_end=true
{"id":"1","key":["AA",0],"value":null},
{"id":"1","key":["AA",1],"value":{"_id":"4"}}

The last example works, but requires me to know what comes after AA in the
results, and you'd think inclusive_end would make BB show up as well.
Has anyone had this problem? Any ideas on how to solve it?

Thanks!

Re: Views with composite keys inclusive_end not functioning correctly

Posted by Danny Brain <te...@gmail.com>.
Hi Eli,

Thanks heaps for the fast response!
I've tried this unsuccessfully previously, and just tried again to verify.

composite_key_view?startkey=["AA"]&endkey=["AA",{}]&inclusive_end=true
No results



On Tue, Sep 28, 2010 at 10:55 AM, Eli Stevens (Gmail)
<wi...@gmail.com>wrote:

> I *think* that instead of using inclusive_end, you want to have
> endkey=["AA", {}] .
>
> The {} is considered to come after all other key values.
>
> Per my understanding, inclusive_end is for when you know *exactly*
> what key you want to stop on.
>
> Eli
>
> On Mon, Sep 27, 2010 at 5:50 PM, Danny Brain <te...@gmail.com> wrote:
> > Hello,
> >
> > I'm having an issue where views with composite keys are not inclusive of
> the
> > endkey, even with inclusive_end specified as true.
> > This is preventing me from correctly selecting a group of documents as
> per
> > the "Linked documents" section on the Http view API wiki page (
> > http://wiki.apache.org/couchdb/Introduction_to_CouchDB_views)
> >
> > I'm running CouchDb 1.0.1. Example of the issue I'm seeing:
> >
> > composite_key_view?startkey=["AA"]&inclusive_end=true
> > {"id":"1","key":["AA",0],"value":null},
> > {"id":"1","key":["AA",1],"value":{"_id":"4"}},
> > {"id":"2","key":["BB",0],"value":null}
> >
> > composite_key_view?startkey=["AA"]&endkey=["AA"]&inclusive_end=true
> > No results
> >
> > composite_key_view?startkey=["AA"]&endkey=["BB"]&inclusive_end=true
> > {"id":"1","key":["AA",0],"value":null},
> > {"id":"1","key":["AA",1],"value":{"_id":"4"}}
> >
> > The last example works, but requires me to know what comes after AA in
> the
> > results, and you'd think inclusive_end would make BB show up as well.
> > Has anyone had this problem? Any ideas on how to solve it?
> >
> > Thanks!
> >
>
>
>
> --
> Eli
>

Re: Views with composite keys inclusive_end not functioning correctly

Posted by "Eli Stevens (Gmail)" <wi...@gmail.com>.
I *think* that instead of using inclusive_end, you want to have
endkey=["AA", {}] .

The {} is considered to come after all other key values.

Per my understanding, inclusive_end is for when you know *exactly*
what key you want to stop on.

Eli

On Mon, Sep 27, 2010 at 5:50 PM, Danny Brain <te...@gmail.com> wrote:
> Hello,
>
> I'm having an issue where views with composite keys are not inclusive of the
> endkey, even with inclusive_end specified as true.
> This is preventing me from correctly selecting a group of documents as per
> the "Linked documents" section on the Http view API wiki page (
> http://wiki.apache.org/couchdb/Introduction_to_CouchDB_views)
>
> I'm running CouchDb 1.0.1. Example of the issue I'm seeing:
>
> composite_key_view?startkey=["AA"]&inclusive_end=true
> {"id":"1","key":["AA",0],"value":null},
> {"id":"1","key":["AA",1],"value":{"_id":"4"}},
> {"id":"2","key":["BB",0],"value":null}
>
> composite_key_view?startkey=["AA"]&endkey=["AA"]&inclusive_end=true
> No results
>
> composite_key_view?startkey=["AA"]&endkey=["BB"]&inclusive_end=true
> {"id":"1","key":["AA",0],"value":null},
> {"id":"1","key":["AA",1],"value":{"_id":"4"}}
>
> The last example works, but requires me to know what comes after AA in the
> results, and you'd think inclusive_end would make BB show up as well.
> Has anyone had this problem? Any ideas on how to solve it?
>
> Thanks!
>



-- 
Eli

Re: Views with composite keys inclusive_end not functioning correctly

Posted by Danny Brain <te...@gmail.com>.
That's the one.
For some reason the startkey was handled fine (without being escaped
correctly), but the endkey was grumpy.

On Tue, Sep 28, 2010 at 4:34 PM, Eli Stevens (Gmail)
<wi...@gmail.com>wrote:

> So it was a (lack of) escaping issue, then?  :)
>
> Eli
>
> On Mon, Sep 27, 2010 at 9:54 PM, Danny Brain <te...@gmail.com> wrote:
> > Thanks Paul. I've located the real source of my problem, the actual keys
> > (not example data) contained + symbols.
> > These were being lost when hitting the view.
> >
> > On Tue, Sep 28, 2010 at 11:28 AM, Paul Davis <
> paul.joseph.davis@gmail.com>wrote:
> >
> >> On Mon, Sep 27, 2010 at 8:50 PM, Danny Brain <te...@gmail.com>
> wrote:
> >> > Hello,
> >> >
> >> > I'm having an issue where views with composite keys are not inclusive
> of
> >> the
> >> > endkey, even with inclusive_end specified as true.
> >> > This is preventing me from correctly selecting a group of documents as
> >> per
> >> > the "Linked documents" section on the Http view API wiki page (
> >> > http://wiki.apache.org/couchdb/Introduction_to_CouchDB_views)
> >> >
> >> > I'm running CouchDb 1.0.1. Example of the issue I'm seeing:
> >> >
> >> > composite_key_view?startkey=["AA"]&inclusive_end=true
> >> > {"id":"1","key":["AA",0],"value":null},
> >> > {"id":"1","key":["AA",1],"value":{"_id":"4"}},
> >> > {"id":"2","key":["BB",0],"value":null}
> >> >
> >> > composite_key_view?startkey=["AA"]&endkey=["AA"]&inclusive_end=true
> >> > No results
> >>
> >> ["AA"] == ["AA"] < ["AA", 0]
> >>
> >> >
> >> > composite_key_view?startkey=["AA"]&endkey=["BB"]&inclusive_end=true
> >> > {"id":"1","key":["AA",0],"value":null},
> >> > {"id":"1","key":["AA",1],"value":{"_id":"4"}}
> >> >
> >>
> >> ["AA"] < ["AA", 0] < ["AA", 1] < ["BB"] < ["BB", 0]
> >>
> >> > The last example works, but requires me to know what comes after AA in
> >> the
> >> > results, and you'd think inclusive_end would make BB show up as well.
> >> > Has anyone had this problem? Any ideas on how to solve it?
> >> >
> >> > Thanks!
> >> >
> >>
> >> In neither example does inclusive_end come into effect.
> >>
> >> To get everything with "AA" as the first element of the array key you
> want:
> >>
> >> ?startkey=["AA"]&endkey=["AA", {}]
> >>
> >> Inclusive end has nothing to do with it.
> >>
> >> HTH,
> >> Paul Davis
> >>
> >
>
>
>
> --
> Eli
>

Re: Views with composite keys inclusive_end not functioning correctly

Posted by "Eli Stevens (Gmail)" <wi...@gmail.com>.
So it was a (lack of) escaping issue, then?  :)

Eli

On Mon, Sep 27, 2010 at 9:54 PM, Danny Brain <te...@gmail.com> wrote:
> Thanks Paul. I've located the real source of my problem, the actual keys
> (not example data) contained + symbols.
> These were being lost when hitting the view.
>
> On Tue, Sep 28, 2010 at 11:28 AM, Paul Davis <pa...@gmail.com>wrote:
>
>> On Mon, Sep 27, 2010 at 8:50 PM, Danny Brain <te...@gmail.com> wrote:
>> > Hello,
>> >
>> > I'm having an issue where views with composite keys are not inclusive of
>> the
>> > endkey, even with inclusive_end specified as true.
>> > This is preventing me from correctly selecting a group of documents as
>> per
>> > the "Linked documents" section on the Http view API wiki page (
>> > http://wiki.apache.org/couchdb/Introduction_to_CouchDB_views)
>> >
>> > I'm running CouchDb 1.0.1. Example of the issue I'm seeing:
>> >
>> > composite_key_view?startkey=["AA"]&inclusive_end=true
>> > {"id":"1","key":["AA",0],"value":null},
>> > {"id":"1","key":["AA",1],"value":{"_id":"4"}},
>> > {"id":"2","key":["BB",0],"value":null}
>> >
>> > composite_key_view?startkey=["AA"]&endkey=["AA"]&inclusive_end=true
>> > No results
>>
>> ["AA"] == ["AA"] < ["AA", 0]
>>
>> >
>> > composite_key_view?startkey=["AA"]&endkey=["BB"]&inclusive_end=true
>> > {"id":"1","key":["AA",0],"value":null},
>> > {"id":"1","key":["AA",1],"value":{"_id":"4"}}
>> >
>>
>> ["AA"] < ["AA", 0] < ["AA", 1] < ["BB"] < ["BB", 0]
>>
>> > The last example works, but requires me to know what comes after AA in
>> the
>> > results, and you'd think inclusive_end would make BB show up as well.
>> > Has anyone had this problem? Any ideas on how to solve it?
>> >
>> > Thanks!
>> >
>>
>> In neither example does inclusive_end come into effect.
>>
>> To get everything with "AA" as the first element of the array key you want:
>>
>> ?startkey=["AA"]&endkey=["AA", {}]
>>
>> Inclusive end has nothing to do with it.
>>
>> HTH,
>> Paul Davis
>>
>



-- 
Eli

Re: Views with composite keys inclusive_end not functioning correctly

Posted by Danny Brain <te...@gmail.com>.
Thanks Paul. I've located the real source of my problem, the actual keys
(not example data) contained + symbols.
These were being lost when hitting the view.

On Tue, Sep 28, 2010 at 11:28 AM, Paul Davis <pa...@gmail.com>wrote:

> On Mon, Sep 27, 2010 at 8:50 PM, Danny Brain <te...@gmail.com> wrote:
> > Hello,
> >
> > I'm having an issue where views with composite keys are not inclusive of
> the
> > endkey, even with inclusive_end specified as true.
> > This is preventing me from correctly selecting a group of documents as
> per
> > the "Linked documents" section on the Http view API wiki page (
> > http://wiki.apache.org/couchdb/Introduction_to_CouchDB_views)
> >
> > I'm running CouchDb 1.0.1. Example of the issue I'm seeing:
> >
> > composite_key_view?startkey=["AA"]&inclusive_end=true
> > {"id":"1","key":["AA",0],"value":null},
> > {"id":"1","key":["AA",1],"value":{"_id":"4"}},
> > {"id":"2","key":["BB",0],"value":null}
> >
> > composite_key_view?startkey=["AA"]&endkey=["AA"]&inclusive_end=true
> > No results
>
> ["AA"] == ["AA"] < ["AA", 0]
>
> >
> > composite_key_view?startkey=["AA"]&endkey=["BB"]&inclusive_end=true
> > {"id":"1","key":["AA",0],"value":null},
> > {"id":"1","key":["AA",1],"value":{"_id":"4"}}
> >
>
> ["AA"] < ["AA", 0] < ["AA", 1] < ["BB"] < ["BB", 0]
>
> > The last example works, but requires me to know what comes after AA in
> the
> > results, and you'd think inclusive_end would make BB show up as well.
> > Has anyone had this problem? Any ideas on how to solve it?
> >
> > Thanks!
> >
>
> In neither example does inclusive_end come into effect.
>
> To get everything with "AA" as the first element of the array key you want:
>
> ?startkey=["AA"]&endkey=["AA", {}]
>
> Inclusive end has nothing to do with it.
>
> HTH,
> Paul Davis
>

Re: Views with composite keys inclusive_end not functioning correctly

Posted by Paul Davis <pa...@gmail.com>.
On Mon, Sep 27, 2010 at 8:50 PM, Danny Brain <te...@gmail.com> wrote:
> Hello,
>
> I'm having an issue where views with composite keys are not inclusive of the
> endkey, even with inclusive_end specified as true.
> This is preventing me from correctly selecting a group of documents as per
> the "Linked documents" section on the Http view API wiki page (
> http://wiki.apache.org/couchdb/Introduction_to_CouchDB_views)
>
> I'm running CouchDb 1.0.1. Example of the issue I'm seeing:
>
> composite_key_view?startkey=["AA"]&inclusive_end=true
> {"id":"1","key":["AA",0],"value":null},
> {"id":"1","key":["AA",1],"value":{"_id":"4"}},
> {"id":"2","key":["BB",0],"value":null}
>
> composite_key_view?startkey=["AA"]&endkey=["AA"]&inclusive_end=true
> No results

["AA"] == ["AA"] < ["AA", 0]

>
> composite_key_view?startkey=["AA"]&endkey=["BB"]&inclusive_end=true
> {"id":"1","key":["AA",0],"value":null},
> {"id":"1","key":["AA",1],"value":{"_id":"4"}}
>

["AA"] < ["AA", 0] < ["AA", 1] < ["BB"] < ["BB", 0]

> The last example works, but requires me to know what comes after AA in the
> results, and you'd think inclusive_end would make BB show up as well.
> Has anyone had this problem? Any ideas on how to solve it?
>
> Thanks!
>

In neither example does inclusive_end come into effect.

To get everything with "AA" as the first element of the array key you want:

?startkey=["AA"]&endkey=["AA", {}]

Inclusive end has nothing to do with it.

HTH,
Paul Davis