incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Filipe David Manana <fdman...@apache.org>
Subject Re: Complex keys and ranges
Date Mon, 01 Nov 2010 17:38:49 GMT
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 <paul.joseph.davis@gmail.com> wrote:
> On Mon, Nov 1, 2010 at 12:56 PM, cdr53x <cdr53x@free.fr> 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,
fdmanana@gmail.com, fdmanana@apache.org

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

Mime
View raw message