incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephan Bardubitzki <step...@bardubitzki.com>
Subject Re: startkey
Date Tue, 16 Jul 2013 03:52:59 GMT
Just for clarification, I'm looking after one map function that can 
create a view where all docs that have the same doc.kml_id, are sorted 
by doc.marker and only contains the description for a particular 
language from the doc.language array.

Is this possible with one map function?



On 13-07-15 07:15 PM, Stephan Bardubitzki wrote:
> And I need the doc.marker too, sorted 0...n? Any example?
>
> What are the {} for?
>
> Thanks again.
> Stephan
>
> On 13-07-15 07:00 PM, Paul Davis wrote:
>> A couple examples might be something like:
>>
>> All rows for French:
>>
>> startkey: ["fr"]
>> endkey: ["fr",{}]
>>
>> All rows for a specific kml_id:
>>
>> starkey: ["fr", id]
>> endkey: ["fr", id, {}]
>>
>>
>>
>> On Mon, Jul 15, 2013 at 8:58 PM, Paul Davis 
>> <paul.joseph.davis@gmail.com>wrote:
>>
>>> Exactly like that yeah.
>>>
>>>
>>> On Mon, Jul 15, 2013 at 8:55 PM, Stephan Bardubitzki <
>>> stephan@bardubitzki.com> wrote:
>>>
>>>> Thanks for your response Paul. I think I'm missing something 
>>>> important.
>>>> How do I tell the view that I just need fr - language and not en, 
>>>> de, es ...
>>>>
>>>> startkey: ["fr", id, 0] ?
>>>>
>>>>
>>>>
>>>> On 13-07-15 03:26 PM, Paul Davis wrote:
>>>>
>>>>> You'll need to add an element to the key to emit the language. Pseudo
>>>>> code:
>>>>>
>>>>> for language in doc["languages"]:
>>>>>        emit([language, doc.kml_id, doc.marker], 1)
>>>>>
>>>>> Also note that its generally not a good idea to emit the doc as the
>>>>> value.
>>>>> You should prefer to use include_docs=true in the query string. 
>>>>> Emitting
>>>>> 1
>>>>> allows you to specify "_sum" as a reduce function to get row 
>>>>> counts for
>>>>> specific start/end key pairs.
>>>>>
>>>>>
>>>>> On Mon, Jul 15, 2013 at 5:07 PM, Stephan Bardubitzki <
>>>>> stephan@bardubitzki.com> wrote:
>>>>>
>>>>>   Hi there,
>>>>>> this map function
>>>>>>
>>>>>> "map": "function(doc) { if (doc.kml_id && doc.marker) {
>>>>>> emit([doc.kml_id,
>>>>>> doc.marker], doc) } }"
>>>>>>
>>>>>> and this startkey
>>>>>>
>>>>>> startkey: [id, 0]    --> sorting doc.marker
>>>>>>
>>>>>> let me retrieve data from a couch as needed.
>>>>>>
>>>>>> Now I got the task to add more languages beside English for 
>>>>>> description
>>>>>> properties in an array structure like this
>>>>>>
>>>>>> "language": [
>>>>>>       {
>>>>>>           "en":{
>>>>>>
>>>>>>                   }
>>>>>>       },
>>>>>>       {
>>>>>>            "fr": {
>>>>>>
>>>>>>                    }
>>>>>>       }
>>>>>> ]
>>>>>>
>>>>>> I stuck in figuring out a startkey that let me retrieve the 
>>>>>> sorted data
>>>>>> only for a particular language.
>>>>>>
>>>>>> Any advice would be really appreciated.
>>>>>>
>>>>>> Thanks,
>>>>>> Stephan
>>>>>>
>>>>>>
>>>>>>   ------------------------------**--
>>>>> Spam/Virus scanning by CanIt Pro
>>>>>
>>>>> For more information see
>>>>> http://www.kgbinternet.com/**SpamFilter.htm<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
>


Mime
View raw message