You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Henrik Skupin <hs...@gmail.com> on 2010/09/12 09:06:50 UTC

endkey doesn't obey limit parameter and always returns entries starting with offset 0

Hi,

For my current Couch application I'm using pagination to show only 50
results per page. To navigate back and forward the endkey vs. startkey
parameters are used. While startkey in combination with limit is working
fine, endkey doesn't return results for [offset(endkey)-limit,
offset(endkey)] but for [0, limit]. This makes pagination impossible for me
and looks like to be a bug. An example you can find here:

http://mozmill.hskupin.info/general/reports

After opening the page click 'Next' twice and check the URL of the
'Previous' link before clicking on it. The endkey parameter will not be
obeyed and a click on that link causes the first page to be opened.

The code can be found at: http://github.com/whimboo/mozmill-dashboard

Is the above problem a known broken behavior and worth filing a bug?

Thanks,
Henrik

Re: endkey doesn't obey limit parameter and always returns entries starting with offset 0

Posted by Henrik Skupin <hs...@gmail.com>.
On Sun, Sep 12, 2010 at 10:18 AM, J Chris Anderson <jc...@apache.org>wrote:


> The right way to do it is to use startkey and limit, as documented here.
>
>        http://guide.couchdb.org/draft/recipes.html#fast
>
>
I'm already using this method and it works fine for the next page but it
will not solve my problem for the previous page. Think about loading the
following page:

http://mozmill.hskupin.info/general/reports?startkey=[%222010-09-04T15:30:02%22]&docid=b2d76c168f83fa5519f2b8855a5cea9e

How can the list function know what's is the first element for the previous
page? As far as I can see the information is not provided by the above
query. The only helpful key I have is the one given above
(%222010-09-04T15:30:02%22) but which is the startkey of the current page.
It could be used as the endkey for the previous page.

This seems to be tricky and looks like that previous links can not really be
implemented in the "fast way" right now.

-- 
Henrik Skupin
QA Engineer
Mozilla Corporation

Re: endkey doesn't obey limit parameter and always returns entries starting with offset 0

Posted by Mikeal Rogers <mi...@gmail.com>.
Without a transaction it's impossible to insure fully consistent results
between pages. startkey + docid is the best we can offer, maybe we should
add a simplified API to jquery.couch.js and document best practices.

-Mikeal

On Sun, Sep 12, 2010 at 9:04 PM, Damien Katz <da...@apache.org> wrote:

> It's possible to do it that way, it just needs a way to navigate down the
> correct btree nodes and it's pretty cheap. But it ceases to be cheap with
> partitioned setups, like in BigCouch.
>
> Also since the index can change between reads, using offset may produce
> values out of order, duplicate or skipped values in your UI. Startkey +
> docid generally produces better semantics.
>
> -Damien
>
>
> On Sep 12, 2010, at 8:21 PM, Randall Leeds wrote:
>
> > Any reason why we don't put a document count in the btree index to make
> skip
> > cheap?
> >>
> >> On Sep 12, 2010, at 9:39 AM, Mikeal Rogers wrote:
> >>
> >>> For pagination you can use the skip parameter instead of trying to
> change
> >>> the startkey for each pagination.
> >>>
> >>> http://wiki.apache.org/couchdb/HTTP_view_API#Querying_Options
> >>>
> >>> ?startkey="foo"&limit=10
> >>> ?startkey="foo"&limit=10&skip=10
> >>> ?startkey="foo"&limit=10&skip=20
> >>>
> >>
> >> You can but you shouldn't.
> >>
> >> The right way to do it is to use startkey and limit, as documented here.
> >>
> >> http://guide.couchdb.org/draft/recipes.html#fast
> >>
> >>>
> >>> On Sun, Sep 12, 2010 at 12:06 AM, Henrik Skupin <hs...@gmail.com>
> > wrote:
> >>>
> >>>> Hi,
> >>>>
> >>>> For my current Couch application I'm using pagination to show only 50
> >>>> results per page. To navigate back and forward the endkey vs. startkey
> >>>> parameters are used. While startkey in combination with limit is
> working
> >>>> fine, endkey doesn't return results for [offset(endkey)-limit,
> >>>> offset(endkey)] but for [0, limit]. This makes pagination impossible
> for
> > me
> >>>> and looks like to be a bug. An example you can find here:
> >>>>
> >>>> http://mozmill.hskupin.info/general/reports
> >>>>
> >>>> After opening the page click 'Next' twice and check the URL of the
> >>>> 'Previous' link before clicking on it. The endkey parameter will not
> be
> >>>> obeyed and a click on that link causes the first page to be opened.
> >>>>
> >>>> The code can be found at: http://github.com/whimboo/mozmill-dashboard
> >>>>
> >>>> Is the above problem a known broken behavior and worth filing a bug?
> >>>>
> >>>> Thanks,
> >>>> Henrik
> >>>>
> >>
>
>

Re: endkey doesn't obey limit parameter and always returns entries starting with offset 0

Posted by Mikeal Rogers <mi...@gmail.com>.
Without a transaction it's impossible to insure fully consistent results
between pages. startkey + docid is the best we can offer, maybe we should
add a simplified API to jquery.couch.js and document best practices.

-Mikeal

On Sun, Sep 12, 2010 at 9:04 PM, Damien Katz <da...@apache.org> wrote:

> It's possible to do it that way, it just needs a way to navigate down the
> correct btree nodes and it's pretty cheap. But it ceases to be cheap with
> partitioned setups, like in BigCouch.
>
> Also since the index can change between reads, using offset may produce
> values out of order, duplicate or skipped values in your UI. Startkey +
> docid generally produces better semantics.
>
> -Damien
>
>
> On Sep 12, 2010, at 8:21 PM, Randall Leeds wrote:
>
> > Any reason why we don't put a document count in the btree index to make
> skip
> > cheap?
> >>
> >> On Sep 12, 2010, at 9:39 AM, Mikeal Rogers wrote:
> >>
> >>> For pagination you can use the skip parameter instead of trying to
> change
> >>> the startkey for each pagination.
> >>>
> >>> http://wiki.apache.org/couchdb/HTTP_view_API#Querying_Options
> >>>
> >>> ?startkey="foo"&limit=10
> >>> ?startkey="foo"&limit=10&skip=10
> >>> ?startkey="foo"&limit=10&skip=20
> >>>
> >>
> >> You can but you shouldn't.
> >>
> >> The right way to do it is to use startkey and limit, as documented here.
> >>
> >> http://guide.couchdb.org/draft/recipes.html#fast
> >>
> >>>
> >>> On Sun, Sep 12, 2010 at 12:06 AM, Henrik Skupin <hs...@gmail.com>
> > wrote:
> >>>
> >>>> Hi,
> >>>>
> >>>> For my current Couch application I'm using pagination to show only 50
> >>>> results per page. To navigate back and forward the endkey vs. startkey
> >>>> parameters are used. While startkey in combination with limit is
> working
> >>>> fine, endkey doesn't return results for [offset(endkey)-limit,
> >>>> offset(endkey)] but for [0, limit]. This makes pagination impossible
> for
> > me
> >>>> and looks like to be a bug. An example you can find here:
> >>>>
> >>>> http://mozmill.hskupin.info/general/reports
> >>>>
> >>>> After opening the page click 'Next' twice and check the URL of the
> >>>> 'Previous' link before clicking on it. The endkey parameter will not
> be
> >>>> obeyed and a click on that link causes the first page to be opened.
> >>>>
> >>>> The code can be found at: http://github.com/whimboo/mozmill-dashboard
> >>>>
> >>>> Is the above problem a known broken behavior and worth filing a bug?
> >>>>
> >>>> Thanks,
> >>>> Henrik
> >>>>
> >>
>
>

Re: endkey doesn't obey limit parameter and always returns entries starting with offset 0

Posted by Damien Katz <da...@apache.org>.
It's possible to do it that way, it just needs a way to navigate down the correct btree nodes and it's pretty cheap. But it ceases to be cheap with partitioned setups, like in BigCouch.

Also since the index can change between reads, using offset may produce values out of order, duplicate or skipped values in your UI. Startkey + docid generally produces better semantics.

-Damien


On Sep 12, 2010, at 8:21 PM, Randall Leeds wrote:

> Any reason why we don't put a document count in the btree index to make skip
> cheap?
>> 
>> On Sep 12, 2010, at 9:39 AM, Mikeal Rogers wrote:
>> 
>>> For pagination you can use the skip parameter instead of trying to change
>>> the startkey for each pagination.
>>> 
>>> http://wiki.apache.org/couchdb/HTTP_view_API#Querying_Options
>>> 
>>> ?startkey="foo"&limit=10
>>> ?startkey="foo"&limit=10&skip=10
>>> ?startkey="foo"&limit=10&skip=20
>>> 
>> 
>> You can but you shouldn't.
>> 
>> The right way to do it is to use startkey and limit, as documented here.
>> 
>> http://guide.couchdb.org/draft/recipes.html#fast
>> 
>>> 
>>> On Sun, Sep 12, 2010 at 12:06 AM, Henrik Skupin <hs...@gmail.com>
> wrote:
>>> 
>>>> Hi,
>>>> 
>>>> For my current Couch application I'm using pagination to show only 50
>>>> results per page. To navigate back and forward the endkey vs. startkey
>>>> parameters are used. While startkey in combination with limit is working
>>>> fine, endkey doesn't return results for [offset(endkey)-limit,
>>>> offset(endkey)] but for [0, limit]. This makes pagination impossible for
> me
>>>> and looks like to be a bug. An example you can find here:
>>>> 
>>>> http://mozmill.hskupin.info/general/reports
>>>> 
>>>> After opening the page click 'Next' twice and check the URL of the
>>>> 'Previous' link before clicking on it. The endkey parameter will not be
>>>> obeyed and a click on that link causes the first page to be opened.
>>>> 
>>>> The code can be found at: http://github.com/whimboo/mozmill-dashboard
>>>> 
>>>> Is the above problem a known broken behavior and worth filing a bug?
>>>> 
>>>> Thanks,
>>>> Henrik
>>>> 
>> 


Re: endkey doesn't obey limit parameter and always returns entries starting with offset 0

Posted by Damien Katz <da...@apache.org>.
It's possible to do it that way, it just needs a way to navigate down the correct btree nodes and it's pretty cheap. But it ceases to be cheap with partitioned setups, like in BigCouch.

Also since the index can change between reads, using offset may produce values out of order, duplicate or skipped values in your UI. Startkey + docid generally produces better semantics.

-Damien


On Sep 12, 2010, at 8:21 PM, Randall Leeds wrote:

> Any reason why we don't put a document count in the btree index to make skip
> cheap?
>> 
>> On Sep 12, 2010, at 9:39 AM, Mikeal Rogers wrote:
>> 
>>> For pagination you can use the skip parameter instead of trying to change
>>> the startkey for each pagination.
>>> 
>>> http://wiki.apache.org/couchdb/HTTP_view_API#Querying_Options
>>> 
>>> ?startkey="foo"&limit=10
>>> ?startkey="foo"&limit=10&skip=10
>>> ?startkey="foo"&limit=10&skip=20
>>> 
>> 
>> You can but you shouldn't.
>> 
>> The right way to do it is to use startkey and limit, as documented here.
>> 
>> http://guide.couchdb.org/draft/recipes.html#fast
>> 
>>> 
>>> On Sun, Sep 12, 2010 at 12:06 AM, Henrik Skupin <hs...@gmail.com>
> wrote:
>>> 
>>>> Hi,
>>>> 
>>>> For my current Couch application I'm using pagination to show only 50
>>>> results per page. To navigate back and forward the endkey vs. startkey
>>>> parameters are used. While startkey in combination with limit is working
>>>> fine, endkey doesn't return results for [offset(endkey)-limit,
>>>> offset(endkey)] but for [0, limit]. This makes pagination impossible for
> me
>>>> and looks like to be a bug. An example you can find here:
>>>> 
>>>> http://mozmill.hskupin.info/general/reports
>>>> 
>>>> After opening the page click 'Next' twice and check the URL of the
>>>> 'Previous' link before clicking on it. The endkey parameter will not be
>>>> obeyed and a click on that link causes the first page to be opened.
>>>> 
>>>> The code can be found at: http://github.com/whimboo/mozmill-dashboard
>>>> 
>>>> Is the above problem a known broken behavior and worth filing a bug?
>>>> 
>>>> Thanks,
>>>> Henrik
>>>> 
>> 


Re: endkey doesn't obey limit parameter and always returns entries starting with offset 0

Posted by Mikeal Rogers <mi...@gmail.com>.
The document count of the db at the time of view generation or the document
count that emits at least one key in the index? Or do you really mean the
number of keys in the index?

On Sun, Sep 12, 2010 at 8:21 PM, Randall Leeds <ra...@gmail.com>wrote:

> Any reason why we don't put a document count in the btree index to make
> skip
> cheap?
> >
> > On Sep 12, 2010, at 9:39 AM, Mikeal Rogers wrote:
> >
> >> For pagination you can use the skip parameter instead of trying to
> change
> >> the startkey for each pagination.
> >>
> >> http://wiki.apache.org/couchdb/HTTP_view_API#Querying_Options
> >>
> >> ?startkey="foo"&limit=10
> >> ?startkey="foo"&limit=10&skip=10
> >> ?startkey="foo"&limit=10&skip=20
> >>
> >
> > You can but you shouldn't.
> >
> > The right way to do it is to use startkey and limit, as documented here.
> >
> > http://guide.couchdb.org/draft/recipes.html#fast
> >
> >>
> >> On Sun, Sep 12, 2010 at 12:06 AM, Henrik Skupin <hs...@gmail.com>
> wrote:
> >>
> >>> Hi,
> >>>
> >>> For my current Couch application I'm using pagination to show only 50
> >>> results per page. To navigate back and forward the endkey vs. startkey
> >>> parameters are used. While startkey in combination with limit is
> working
> >>> fine, endkey doesn't return results for [offset(endkey)-limit,
> >>> offset(endkey)] but for [0, limit]. This makes pagination impossible
> for
> me
> >>> and looks like to be a bug. An example you can find here:
> >>>
> >>> http://mozmill.hskupin.info/general/reports
> >>>
> >>> After opening the page click 'Next' twice and check the URL of the
> >>> 'Previous' link before clicking on it. The endkey parameter will not be
> >>> obeyed and a click on that link causes the first page to be opened.
> >>>
> >>> The code can be found at: http://github.com/whimboo/mozmill-dashboard
> >>>
> >>> Is the above problem a known broken behavior and worth filing a bug?
> >>>
> >>> Thanks,
> >>> Henrik
> >>>
> >
>

Re: endkey doesn't obey limit parameter and always returns entries starting with offset 0

Posted by Mikeal Rogers <mi...@gmail.com>.
The document count of the db at the time of view generation or the document
count that emits at least one key in the index? Or do you really mean the
number of keys in the index?

On Sun, Sep 12, 2010 at 8:21 PM, Randall Leeds <ra...@gmail.com>wrote:

> Any reason why we don't put a document count in the btree index to make
> skip
> cheap?
> >
> > On Sep 12, 2010, at 9:39 AM, Mikeal Rogers wrote:
> >
> >> For pagination you can use the skip parameter instead of trying to
> change
> >> the startkey for each pagination.
> >>
> >> http://wiki.apache.org/couchdb/HTTP_view_API#Querying_Options
> >>
> >> ?startkey="foo"&limit=10
> >> ?startkey="foo"&limit=10&skip=10
> >> ?startkey="foo"&limit=10&skip=20
> >>
> >
> > You can but you shouldn't.
> >
> > The right way to do it is to use startkey and limit, as documented here.
> >
> > http://guide.couchdb.org/draft/recipes.html#fast
> >
> >>
> >> On Sun, Sep 12, 2010 at 12:06 AM, Henrik Skupin <hs...@gmail.com>
> wrote:
> >>
> >>> Hi,
> >>>
> >>> For my current Couch application I'm using pagination to show only 50
> >>> results per page. To navigate back and forward the endkey vs. startkey
> >>> parameters are used. While startkey in combination with limit is
> working
> >>> fine, endkey doesn't return results for [offset(endkey)-limit,
> >>> offset(endkey)] but for [0, limit]. This makes pagination impossible
> for
> me
> >>> and looks like to be a bug. An example you can find here:
> >>>
> >>> http://mozmill.hskupin.info/general/reports
> >>>
> >>> After opening the page click 'Next' twice and check the URL of the
> >>> 'Previous' link before clicking on it. The endkey parameter will not be
> >>> obeyed and a click on that link causes the first page to be opened.
> >>>
> >>> The code can be found at: http://github.com/whimboo/mozmill-dashboard
> >>>
> >>> Is the above problem a known broken behavior and worth filing a bug?
> >>>
> >>> Thanks,
> >>> Henrik
> >>>
> >
>

Re: endkey doesn't obey limit parameter and always returns entries starting with offset 0

Posted by Randall Leeds <ra...@gmail.com>.
Any reason why we don't put a document count in the btree index to make skip
cheap?
>
> On Sep 12, 2010, at 9:39 AM, Mikeal Rogers wrote:
>
>> For pagination you can use the skip parameter instead of trying to change
>> the startkey for each pagination.
>>
>> http://wiki.apache.org/couchdb/HTTP_view_API#Querying_Options
>>
>> ?startkey="foo"&limit=10
>> ?startkey="foo"&limit=10&skip=10
>> ?startkey="foo"&limit=10&skip=20
>>
>
> You can but you shouldn't.
>
> The right way to do it is to use startkey and limit, as documented here.
>
> http://guide.couchdb.org/draft/recipes.html#fast
>
>>
>> On Sun, Sep 12, 2010 at 12:06 AM, Henrik Skupin <hs...@gmail.com>
wrote:
>>
>>> Hi,
>>>
>>> For my current Couch application I'm using pagination to show only 50
>>> results per page. To navigate back and forward the endkey vs. startkey
>>> parameters are used. While startkey in combination with limit is working
>>> fine, endkey doesn't return results for [offset(endkey)-limit,
>>> offset(endkey)] but for [0, limit]. This makes pagination impossible for
me
>>> and looks like to be a bug. An example you can find here:
>>>
>>> http://mozmill.hskupin.info/general/reports
>>>
>>> After opening the page click 'Next' twice and check the URL of the
>>> 'Previous' link before clicking on it. The endkey parameter will not be
>>> obeyed and a click on that link causes the first page to be opened.
>>>
>>> The code can be found at: http://github.com/whimboo/mozmill-dashboard
>>>
>>> Is the above problem a known broken behavior and worth filing a bug?
>>>
>>> Thanks,
>>> Henrik
>>>
>

Re: endkey doesn't obey limit parameter and always returns entries starting with offset 0

Posted by Randall Leeds <ra...@gmail.com>.
Any reason why we don't put a document count in the btree index to make skip
cheap?
>
> On Sep 12, 2010, at 9:39 AM, Mikeal Rogers wrote:
>
>> For pagination you can use the skip parameter instead of trying to change
>> the startkey for each pagination.
>>
>> http://wiki.apache.org/couchdb/HTTP_view_API#Querying_Options
>>
>> ?startkey="foo"&limit=10
>> ?startkey="foo"&limit=10&skip=10
>> ?startkey="foo"&limit=10&skip=20
>>
>
> You can but you shouldn't.
>
> The right way to do it is to use startkey and limit, as documented here.
>
> http://guide.couchdb.org/draft/recipes.html#fast
>
>>
>> On Sun, Sep 12, 2010 at 12:06 AM, Henrik Skupin <hs...@gmail.com>
wrote:
>>
>>> Hi,
>>>
>>> For my current Couch application I'm using pagination to show only 50
>>> results per page. To navigate back and forward the endkey vs. startkey
>>> parameters are used. While startkey in combination with limit is working
>>> fine, endkey doesn't return results for [offset(endkey)-limit,
>>> offset(endkey)] but for [0, limit]. This makes pagination impossible for
me
>>> and looks like to be a bug. An example you can find here:
>>>
>>> http://mozmill.hskupin.info/general/reports
>>>
>>> After opening the page click 'Next' twice and check the URL of the
>>> 'Previous' link before clicking on it. The endkey parameter will not be
>>> obeyed and a click on that link causes the first page to be opened.
>>>
>>> The code can be found at: http://github.com/whimboo/mozmill-dashboard
>>>
>>> Is the above problem a known broken behavior and worth filing a bug?
>>>
>>> Thanks,
>>> Henrik
>>>
>

Re: endkey doesn't obey limit parameter and always returns entries starting with offset 0

Posted by Mikeal Rogers <mi...@gmail.com>.
That gets hard when you have the same key emitted multiple times in a view,
then you need to code up and tool moving the startkey + skip in some cases.

This isn't actually 100% solved but the easiest way to handle it is
limit+skip ATM.

-Mikeal

On Sun, Sep 12, 2010 at 10:18 AM, J Chris Anderson <jc...@apache.org>wrote:

>
> On Sep 12, 2010, at 9:39 AM, Mikeal Rogers wrote:
>
> > For pagination you can use the skip parameter instead of trying to change
> > the startkey for each pagination.
> >
> > http://wiki.apache.org/couchdb/HTTP_view_API#Querying_Options
> >
> > ?startkey="foo"&limit=10
> > ?startkey="foo"&limit=10&skip=10
> > ?startkey="foo"&limit=10&skip=20
> >
>
> You can but you shouldn't.
>
> The right way to do it is to use startkey and limit, as documented here.
>
>        http://guide.couchdb.org/draft/recipes.html#fast
>
> >
> > On Sun, Sep 12, 2010 at 12:06 AM, Henrik Skupin <hs...@gmail.com>
> wrote:
> >
> >> Hi,
> >>
> >> For my current Couch application I'm using pagination to show only 50
> >> results per page. To navigate back and forward the endkey vs. startkey
> >> parameters are used. While startkey in combination with limit is working
> >> fine, endkey doesn't return results for [offset(endkey)-limit,
> >> offset(endkey)] but for [0, limit]. This makes pagination impossible for
> me
> >> and looks like to be a bug. An example you can find here:
> >>
> >> http://mozmill.hskupin.info/general/reports
> >>
> >> After opening the page click 'Next' twice and check the URL of the
> >> 'Previous' link before clicking on it. The endkey parameter will not be
> >> obeyed and a click on that link causes the first page to be opened.
> >>
> >> The code can be found at: http://github.com/whimboo/mozmill-dashboard
> >>
> >> Is the above problem a known broken behavior and worth filing a bug?
> >>
> >> Thanks,
> >> Henrik
> >>
>
>

Re: endkey doesn't obey limit parameter and always returns entries starting with offset 0

Posted by J Chris Anderson <jc...@apache.org>.
On Sep 12, 2010, at 9:39 AM, Mikeal Rogers wrote:

> For pagination you can use the skip parameter instead of trying to change
> the startkey for each pagination.
> 
> http://wiki.apache.org/couchdb/HTTP_view_API#Querying_Options
> 
> ?startkey="foo"&limit=10
> ?startkey="foo"&limit=10&skip=10
> ?startkey="foo"&limit=10&skip=20
> 

You can but you shouldn't.

The right way to do it is to use startkey and limit, as documented here.

	http://guide.couchdb.org/draft/recipes.html#fast

> 
> On Sun, Sep 12, 2010 at 12:06 AM, Henrik Skupin <hs...@gmail.com> wrote:
> 
>> Hi,
>> 
>> For my current Couch application I'm using pagination to show only 50
>> results per page. To navigate back and forward the endkey vs. startkey
>> parameters are used. While startkey in combination with limit is working
>> fine, endkey doesn't return results for [offset(endkey)-limit,
>> offset(endkey)] but for [0, limit]. This makes pagination impossible for me
>> and looks like to be a bug. An example you can find here:
>> 
>> http://mozmill.hskupin.info/general/reports
>> 
>> After opening the page click 'Next' twice and check the URL of the
>> 'Previous' link before clicking on it. The endkey parameter will not be
>> obeyed and a click on that link causes the first page to be opened.
>> 
>> The code can be found at: http://github.com/whimboo/mozmill-dashboard
>> 
>> Is the above problem a known broken behavior and worth filing a bug?
>> 
>> Thanks,
>> Henrik
>> 


Re: endkey doesn't obey limit parameter and always returns entries starting with offset 0

Posted by Mikeal Rogers <mi...@gmail.com>.
For pagination you can use the skip parameter instead of trying to change
the startkey for each pagination.

http://wiki.apache.org/couchdb/HTTP_view_API#Querying_Options

?startkey="foo"&limit=10
?startkey="foo"&limit=10&skip=10
?startkey="foo"&limit=10&skip=20


On Sun, Sep 12, 2010 at 12:06 AM, Henrik Skupin <hs...@gmail.com> wrote:

> Hi,
>
> For my current Couch application I'm using pagination to show only 50
> results per page. To navigate back and forward the endkey vs. startkey
> parameters are used. While startkey in combination with limit is working
> fine, endkey doesn't return results for [offset(endkey)-limit,
> offset(endkey)] but for [0, limit]. This makes pagination impossible for me
> and looks like to be a bug. An example you can find here:
>
> http://mozmill.hskupin.info/general/reports
>
> After opening the page click 'Next' twice and check the URL of the
> 'Previous' link before clicking on it. The endkey parameter will not be
> obeyed and a click on that link causes the first page to be opened.
>
> The code can be found at: http://github.com/whimboo/mozmill-dashboard
>
> Is the above problem a known broken behavior and worth filing a bug?
>
> Thanks,
> Henrik
>

Re: endkey doesn't obey limit parameter and always returns entries starting with offset 0

Posted by Sebastian Cohnen <se...@googlemail.com>.
Hey Henrik,

this does not sound like a bug.

You need to specify a startkey, if you want proper pagination. couch streams results from the index from startkey to endkey, but limited to the given limit parameter. if you don't provide a startkey, couch will stream from the beginning (AFAIK) up to endkey when the limit of results is hit (whichever comes first). this is the reason why you will always see the first "page" in your application.

I'm not sure if there is an example in the couchdb book or in the wiki, but sofa (jchris' blog couchapp) has pagination build in. Maybe you can have a look there (http://github.com/jchris/sofa). Pagination is best build using startkey and limit.


Best

Sebastian

On 12.09.2010, at 09:06, Henrik Skupin wrote:

> Hi,
> 
> For my current Couch application I'm using pagination to show only 50
> results per page. To navigate back and forward the endkey vs. startkey
> parameters are used. While startkey in combination with limit is working
> fine, endkey doesn't return results for [offset(endkey)-limit,
> offset(endkey)] but for [0, limit]. This makes pagination impossible for me
> and looks like to be a bug. An example you can find here:
> 
> http://mozmill.hskupin.info/general/reports
> 
> After opening the page click 'Next' twice and check the URL of the
> 'Previous' link before clicking on it. The endkey parameter will not be
> obeyed and a click on that link causes the first page to be opened.
> 
> The code can be found at: http://github.com/whimboo/mozmill-dashboard
> 
> Is the above problem a known broken behavior and worth filing a bug?
> 
> Thanks,
> Henrik