Also note that it's "startkey" and "endkey", not "start_key" nor "end_key".

On Mon, Nov 1, 2010 at 5:10 PM, Paul Davis <[email protected]> wrote:
> On Mon, Nov 1, 2010 at 12:56 PM, cdr53x <[email protected]> wrote:
>> Hello,
>>
>> I've read all the docs/wiki again but cannot find anything related to views
>> usage when keys are complex JSON objects.
>>
>> Especially, there are no explanations nor examples of how the ranges (
>> startkey/endkey ) are supposed to behave with complex keys.
>>
>> For instance let's presume we have the a view with the following map
>> function :
>>
>> function(doc) {
>>    ...
>>    emit({ 'date' : created_at  , 'author' : author}, null) ;
>> }
>>
>>
>> Would it be possible to "filter" on both date and author ?
>>
>> For instance get all the docs created in a given time range by a given
>> author , by passing a range like  :
>>
>>  start_key : { 'date' : '201002030000.' , author : 'adams' }
>>  end_key   : { 'date' : '201003030000.' , author : 'adams' }
>>
>> ?
>>
>> I have tried this however it does not seem to work that way, so if anyone
>> has some info on how this should work, I'd really appreciate
>>
>> Thanks in advance,
>>
>> cdrx
>>
>
> View collation is specified here:
> http://wiki.apache.org/couchdb/View_collation#Collation_Specification
>
>
> In short, no, its not possible to filter on multiple members of an
> object key. Generally speaking you shouldn't use object keys as they
> can lead to confusing behavior that is dependent on the various JSON
> libraries used for serialization. If you need complex keys its
> generally best to stick to Arrays as their sorting behavior easier to
> reason about.
>
> HTH,
> Paul Davis
>



-- 
Filipe David Manana,
[email protected], [email protected]

"Reasonable men adapt themselves to the world.
 Unreasonable men adapt the world to themselves.
 That's why all progress depends on unreasonable men."

Reply via email to