couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From muji <freeformsyst...@gmail.com>
Subject Re: Is pagination possible with multiple keys query?
Date Thu, 25 Oct 2012 17:26:35 GMT
My understanding is no it's not possible when using multiple keys to
query a view, but I would love to be corrected.

My use case was a tree-style taxonomy where I wanted to be able to
query a view to show all the items that belonged to a *parent* in the
taxonomy and then paginate those. But the restriction of startkey and
startkey_docid only enabling a single key prevented this option. I did
not want to use the *skip* style pagination because of the performance
implications.

My solution (which I am yet to fully implement) is to dynamically
create a view as the taxonomy is modified, so I will end up with a map
function for each non-leaf node of the tree:

bcd_jacket:
		{
			map: function( doc )
			{
				if( doc.parent == 'bcd/jacket' && doc['equipment-type'] == 'item' )
				{
					emit( doc.parent, null );
				}
			}
		}

No doubt there is a better way, but I am yet to find it ;)

2012/10/25 Aliaksandr Barysiuk <a.barysiuk@gmail.com>:
> Hello,
>
> http://guide.couchdb.org/editions/1/en/recipes.html, pagination chapter.
> Short answer: you can try to use startkey+ startkey_docid
>
>
> On 25/10/12 18:58, Dirkjan Ochtman wrote:
>>
>> On Thu, Oct 25, 2012 at 5:54 PM, boazc <bcitrin@gmail.com> wrote:
>>>
>>> Using "keys" with "startkey" is not possible, so I don't know how to tell
>>> couchdb to start from a given document of a given key (in my case of
>>> using
>>> "keys" parameter).
>>
>> Please discuss this on the user list, not the dev list.
>>
>> Cheers,
>>
>> Dirkjan
>
>



-- 
mischa (aka muji).

Mime
View raw message