You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Stephan Bardubitzki <st...@bardubitzki.com> on 2013/07/17 20:17:17 UTC
View Collation
In my docs I have a Number property starting at 0. My start/end key
looks like this:
startkey: ["fr", id, 0]. endkey: ["fr", id, {}]
to sort the response by this property. It seems to work well, however,
the doc with the property value=0 is omitted.
I presume the view collation for numbers is starting at 1?
Re: View Collation
Posted by Stephan Bardubitzki <st...@bardubitzki.com>.
I choose your second suggestion and it works like a charm.
Thanks,
Stephan
On 13-07-17 12:06 PM, Jeff Snider wrote:
> Sorry, that wasn't real clear without formatting. Here's what I mean:
>
> if (doc.kml_id && 'marker' in doc && doc.language) {
>
> or even
>
> if ('kml_id' in doc && 'marker' in doc && 'language' in doc) {
>
>
> I think that should do what you want.
>
>
>
>
>
> On Jul 17, 2013, at 2:02 PM, Jeff Snider wrote:
>
>> You are checking doc.marker in your if statement. 0 in JS is false, so nothing is emitted for the doc when marker is 0. Try 'marker' in doc instead if you're going to have falsy values in there.
>>
>>
>>
>>
>>
>> On Jul 17, 2013, at 1:41 PM, Stephan Bardubitzki wrote:
>>
>>> I see, thanks.
>>>
>>> Still, the doc with doc.marker: 0 is omitted.
>>>
>>>
>>> On 13-07-17 11:34 AM, Robert Newson wrote:
>>>> Sure, but shorter arrays sort earlier than longer ones, so ["fr", id]
>>>> sorts before any 3-item array, and thus before ["fr",id,0]. :)
>>>>
>>>> On 17 July 2013 19:32, Stephan Bardubitzki <st...@bardubitzki.com> wrote:
>>>>> The third element in the startkey is the number property to be sorted. Here
>>>>> is my map function:
>>>>>
>>>>> function(doc) {
>>>>> if (doc.kml_id && doc.marker && doc.language) {
>>>>> for (language in doc['language']) {
>>>>> var o = {};
>>>>> o.description = doc.language[language];
>>>>> o.gps = doc.gps;
>>>>> emit([language, doc.kml_id, doc.marker], o);
>>>>>
>>>>> }
>>>>> }
>>>>> }
>>>>>
>>>>> On 13-07-17 11:21 AM, Robert Newson wrote:
>>>>>> Use start key of ["fr",id]
>>>>>> On 17 Jul 2013 19:18, "Stephan Bardubitzki" <st...@bardubitzki.com>
>>>>>> wrote:
>>>>>>
>>>>>>> In my docs I have a Number property starting at 0. My start/end key looks
>>>>>>> like this:
>>>>>>>
>>>>>>> startkey: ["fr", id, 0]. endkey: ["fr", id, {}]
>>>>>>>
>>>>>>> to sort the response by this property. It seems to work well, however,
>>>>>>> the
>>>>>>> doc with the property value=0 is omitted.
>>>>>>>
>>>>>>> I presume the view collation for numbers is starting at 1?
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> --------------------------------
>>>>>> Spam/Virus scanning by CanIt Pro
>>>>>>
>>>>>> For more information see
>>>>>> http://www.kgbinternet.com/SpamFilter.htm
>>>>>>
>>>>>> To control your spam filter, log in at
>>>>>> http://filter.kgbinternet.com
>>>>>>
>>>> --------------------------------
>>>> Spam/Virus scanning by CanIt Pro
>>>>
>>>> For more information see
>>>> http://www.kgbinternet.com/SpamFilter.htm
>>>>
>>>> To control your spam filter, log in at
>>>> http://filter.kgbinternet.com
>>>>
>
> --------------------------------
> Spam/Virus scanning by CanIt Pro
>
> For more information see
> http://www.kgbinternet.com/SpamFilter.htm
>
> To control your spam filter, log in at
> http://filter.kgbinternet.com
>
Re: View Collation
Posted by Robert Newson <rn...@apache.org>.
Hah, good find! I've done that myself...
On 17 July 2013 20:06, Jeff Snider <je...@jsnider.net> wrote:
> Sorry, that wasn't real clear without formatting. Here's what I mean:
>
> if (doc.kml_id && 'marker' in doc && doc.language) {
>
> or even
>
> if ('kml_id' in doc && 'marker' in doc && 'language' in doc) {
>
>
> I think that should do what you want.
>
>
>
>
>
> On Jul 17, 2013, at 2:02 PM, Jeff Snider wrote:
>
>> You are checking doc.marker in your if statement. 0 in JS is false, so nothing is emitted for the doc when marker is 0. Try 'marker' in doc instead if you're going to have falsy values in there.
>>
>>
>>
>>
>>
>> On Jul 17, 2013, at 1:41 PM, Stephan Bardubitzki wrote:
>>
>>> I see, thanks.
>>>
>>> Still, the doc with doc.marker: 0 is omitted.
>>>
>>>
>>> On 13-07-17 11:34 AM, Robert Newson wrote:
>>>> Sure, but shorter arrays sort earlier than longer ones, so ["fr", id]
>>>> sorts before any 3-item array, and thus before ["fr",id,0]. :)
>>>>
>>>> On 17 July 2013 19:32, Stephan Bardubitzki <st...@bardubitzki.com> wrote:
>>>>> The third element in the startkey is the number property to be sorted. Here
>>>>> is my map function:
>>>>>
>>>>> function(doc) {
>>>>> if (doc.kml_id && doc.marker && doc.language) {
>>>>> for (language in doc['language']) {
>>>>> var o = {};
>>>>> o.description = doc.language[language];
>>>>> o.gps = doc.gps;
>>>>> emit([language, doc.kml_id, doc.marker], o);
>>>>>
>>>>> }
>>>>> }
>>>>> }
>>>>>
>>>>> On 13-07-17 11:21 AM, Robert Newson wrote:
>>>>>> Use start key of ["fr",id]
>>>>>> On 17 Jul 2013 19:18, "Stephan Bardubitzki" <st...@bardubitzki.com>
>>>>>> wrote:
>>>>>>
>>>>>>> In my docs I have a Number property starting at 0. My start/end key looks
>>>>>>> like this:
>>>>>>>
>>>>>>> startkey: ["fr", id, 0]. endkey: ["fr", id, {}]
>>>>>>>
>>>>>>> to sort the response by this property. It seems to work well, however,
>>>>>>> the
>>>>>>> doc with the property value=0 is omitted.
>>>>>>>
>>>>>>> I presume the view collation for numbers is starting at 1?
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> --------------------------------
>>>>>> Spam/Virus scanning by CanIt Pro
>>>>>>
>>>>>> For more information see
>>>>>> http://www.kgbinternet.com/SpamFilter.htm
>>>>>>
>>>>>> To control your spam filter, log in at
>>>>>> http://filter.kgbinternet.com
>>>>>>
>>>> --------------------------------
>>>> Spam/Virus scanning by CanIt Pro
>>>>
>>>> For more information see
>>>> http://www.kgbinternet.com/SpamFilter.htm
>>>>
>>>> To control your spam filter, log in at
>>>> http://filter.kgbinternet.com
>>>>
>>>
>>
>
Re: View Collation
Posted by Jeff Snider <je...@jsnider.net>.
Sorry, that wasn't real clear without formatting. Here's what I mean:
if (doc.kml_id && 'marker' in doc && doc.language) {
or even
if ('kml_id' in doc && 'marker' in doc && 'language' in doc) {
I think that should do what you want.
On Jul 17, 2013, at 2:02 PM, Jeff Snider wrote:
> You are checking doc.marker in your if statement. 0 in JS is false, so nothing is emitted for the doc when marker is 0. Try 'marker' in doc instead if you're going to have falsy values in there.
>
>
>
>
>
> On Jul 17, 2013, at 1:41 PM, Stephan Bardubitzki wrote:
>
>> I see, thanks.
>>
>> Still, the doc with doc.marker: 0 is omitted.
>>
>>
>> On 13-07-17 11:34 AM, Robert Newson wrote:
>>> Sure, but shorter arrays sort earlier than longer ones, so ["fr", id]
>>> sorts before any 3-item array, and thus before ["fr",id,0]. :)
>>>
>>> On 17 July 2013 19:32, Stephan Bardubitzki <st...@bardubitzki.com> wrote:
>>>> The third element in the startkey is the number property to be sorted. Here
>>>> is my map function:
>>>>
>>>> function(doc) {
>>>> if (doc.kml_id && doc.marker && doc.language) {
>>>> for (language in doc['language']) {
>>>> var o = {};
>>>> o.description = doc.language[language];
>>>> o.gps = doc.gps;
>>>> emit([language, doc.kml_id, doc.marker], o);
>>>>
>>>> }
>>>> }
>>>> }
>>>>
>>>> On 13-07-17 11:21 AM, Robert Newson wrote:
>>>>> Use start key of ["fr",id]
>>>>> On 17 Jul 2013 19:18, "Stephan Bardubitzki" <st...@bardubitzki.com>
>>>>> wrote:
>>>>>
>>>>>> In my docs I have a Number property starting at 0. My start/end key looks
>>>>>> like this:
>>>>>>
>>>>>> startkey: ["fr", id, 0]. endkey: ["fr", id, {}]
>>>>>>
>>>>>> to sort the response by this property. It seems to work well, however,
>>>>>> the
>>>>>> doc with the property value=0 is omitted.
>>>>>>
>>>>>> I presume the view collation for numbers is starting at 1?
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>> --------------------------------
>>>>> Spam/Virus scanning by CanIt Pro
>>>>>
>>>>> For more information see
>>>>> http://www.kgbinternet.com/SpamFilter.htm
>>>>>
>>>>> To control your spam filter, log in at
>>>>> http://filter.kgbinternet.com
>>>>>
>>> --------------------------------
>>> Spam/Virus scanning by CanIt Pro
>>>
>>> For more information see
>>> http://www.kgbinternet.com/SpamFilter.htm
>>>
>>> To control your spam filter, log in at
>>> http://filter.kgbinternet.com
>>>
>>
>
Re: View Collation
Posted by Jeff Snider <je...@jsnider.net>.
You are checking doc.marker in your if statement. 0 in JS is false, so nothing is emitted for the doc when marker is 0. Try 'marker' in doc instead if you're going to have falsy values in there.
On Jul 17, 2013, at 1:41 PM, Stephan Bardubitzki wrote:
> I see, thanks.
>
> Still, the doc with doc.marker: 0 is omitted.
>
>
> On 13-07-17 11:34 AM, Robert Newson wrote:
>> Sure, but shorter arrays sort earlier than longer ones, so ["fr", id]
>> sorts before any 3-item array, and thus before ["fr",id,0]. :)
>>
>> On 17 July 2013 19:32, Stephan Bardubitzki <st...@bardubitzki.com> wrote:
>>> The third element in the startkey is the number property to be sorted. Here
>>> is my map function:
>>>
>>> function(doc) {
>>> if (doc.kml_id && doc.marker && doc.language) {
>>> for (language in doc['language']) {
>>> var o = {};
>>> o.description = doc.language[language];
>>> o.gps = doc.gps;
>>> emit([language, doc.kml_id, doc.marker], o);
>>>
>>> }
>>> }
>>> }
>>>
>>> On 13-07-17 11:21 AM, Robert Newson wrote:
>>>> Use start key of ["fr",id]
>>>> On 17 Jul 2013 19:18, "Stephan Bardubitzki" <st...@bardubitzki.com>
>>>> wrote:
>>>>
>>>>> In my docs I have a Number property starting at 0. My start/end key looks
>>>>> like this:
>>>>>
>>>>> startkey: ["fr", id, 0]. endkey: ["fr", id, {}]
>>>>>
>>>>> to sort the response by this property. It seems to work well, however,
>>>>> the
>>>>> doc with the property value=0 is omitted.
>>>>>
>>>>> I presume the view collation for numbers is starting at 1?
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>> --------------------------------
>>>> Spam/Virus scanning by CanIt Pro
>>>>
>>>> For more information see
>>>> http://www.kgbinternet.com/SpamFilter.htm
>>>>
>>>> To control your spam filter, log in at
>>>> http://filter.kgbinternet.com
>>>>
>> --------------------------------
>> Spam/Virus scanning by CanIt Pro
>>
>> For more information see
>> http://www.kgbinternet.com/SpamFilter.htm
>>
>> To control your spam filter, log in at
>> http://filter.kgbinternet.com
>>
>
Re: View Collation
Posted by Stephan Bardubitzki <st...@bardubitzki.com>.
I see, thanks.
Still, the doc with doc.marker: 0 is omitted.
On 13-07-17 11:34 AM, Robert Newson wrote:
> Sure, but shorter arrays sort earlier than longer ones, so ["fr", id]
> sorts before any 3-item array, and thus before ["fr",id,0]. :)
>
> On 17 July 2013 19:32, Stephan Bardubitzki <st...@bardubitzki.com> wrote:
>> The third element in the startkey is the number property to be sorted. Here
>> is my map function:
>>
>> function(doc) {
>> if (doc.kml_id && doc.marker && doc.language) {
>> for (language in doc['language']) {
>> var o = {};
>> o.description = doc.language[language];
>> o.gps = doc.gps;
>> emit([language, doc.kml_id, doc.marker], o);
>>
>> }
>> }
>> }
>>
>> On 13-07-17 11:21 AM, Robert Newson wrote:
>>> Use start key of ["fr",id]
>>> On 17 Jul 2013 19:18, "Stephan Bardubitzki" <st...@bardubitzki.com>
>>> wrote:
>>>
>>>> In my docs I have a Number property starting at 0. My start/end key looks
>>>> like this:
>>>>
>>>> startkey: ["fr", id, 0]. endkey: ["fr", id, {}]
>>>>
>>>> to sort the response by this property. It seems to work well, however,
>>>> the
>>>> doc with the property value=0 is omitted.
>>>>
>>>> I presume the view collation for numbers is starting at 1?
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>> --------------------------------
>>> Spam/Virus scanning by CanIt Pro
>>>
>>> For more information see
>>> http://www.kgbinternet.com/SpamFilter.htm
>>>
>>> To control your spam filter, log in at
>>> http://filter.kgbinternet.com
>>>
> --------------------------------
> Spam/Virus scanning by CanIt Pro
>
> For more information see
> http://www.kgbinternet.com/SpamFilter.htm
>
> To control your spam filter, log in at
> http://filter.kgbinternet.com
>
Re: View Collation
Posted by Robert Newson <rn...@apache.org>.
Sure, but shorter arrays sort earlier than longer ones, so ["fr", id]
sorts before any 3-item array, and thus before ["fr",id,0]. :)
On 17 July 2013 19:32, Stephan Bardubitzki <st...@bardubitzki.com> wrote:
> The third element in the startkey is the number property to be sorted. Here
> is my map function:
>
> function(doc) {
> if (doc.kml_id && doc.marker && doc.language) {
> for (language in doc['language']) {
> var o = {};
> o.description = doc.language[language];
> o.gps = doc.gps;
> emit([language, doc.kml_id, doc.marker], o);
>
> }
> }
> }
>
> On 13-07-17 11:21 AM, Robert Newson wrote:
>>
>> Use start key of ["fr",id]
>> On 17 Jul 2013 19:18, "Stephan Bardubitzki" <st...@bardubitzki.com>
>> wrote:
>>
>>> In my docs I have a Number property starting at 0. My start/end key looks
>>> like this:
>>>
>>> startkey: ["fr", id, 0]. endkey: ["fr", id, {}]
>>>
>>> to sort the response by this property. It seems to work well, however,
>>> the
>>> doc with the property value=0 is omitted.
>>>
>>> I presume the view collation for numbers is starting at 1?
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>> --------------------------------
>> Spam/Virus scanning by CanIt Pro
>>
>> For more information see
>> http://www.kgbinternet.com/SpamFilter.htm
>>
>> To control your spam filter, log in at
>> http://filter.kgbinternet.com
>>
>
Re: View Collation
Posted by Stephan Bardubitzki <st...@bardubitzki.com>.
The third element in the startkey is the number property to be sorted.
Here is my map function:
function(doc) {
if (doc.kml_id && doc.marker && doc.language) {
for (language in doc['language']) {
var o = {};
o.description = doc.language[language];
o.gps = doc.gps;
emit([language, doc.kml_id, doc.marker], o);
}
}
}
On 13-07-17 11:21 AM, Robert Newson wrote:
> Use start key of ["fr",id]
> On 17 Jul 2013 19:18, "Stephan Bardubitzki" <st...@bardubitzki.com> wrote:
>
>> In my docs I have a Number property starting at 0. My start/end key looks
>> like this:
>>
>> startkey: ["fr", id, 0]. endkey: ["fr", id, {}]
>>
>> to sort the response by this property. It seems to work well, however, the
>> doc with the property value=0 is omitted.
>>
>> I presume the view collation for numbers is starting at 1?
>>
>>
>>
>>
>>
>>
>>
> --------------------------------
> Spam/Virus scanning by CanIt Pro
>
> For more information see
> http://www.kgbinternet.com/SpamFilter.htm
>
> To control your spam filter, log in at
> http://filter.kgbinternet.com
>
Re: View Collation
Posted by Robert Newson <rn...@apache.org>.
Use start key of ["fr",id]
On 17 Jul 2013 19:18, "Stephan Bardubitzki" <st...@bardubitzki.com> wrote:
> In my docs I have a Number property starting at 0. My start/end key looks
> like this:
>
> startkey: ["fr", id, 0]. endkey: ["fr", id, {}]
>
> to sort the response by this property. It seems to work well, however, the
> doc with the property value=0 is omitted.
>
> I presume the view collation for numbers is starting at 1?
>
>
>
>
>
>
>