Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E6B6D10A99 for ; Tue, 16 Jul 2013 22:53:00 +0000 (UTC) Received: (qmail 46164 invoked by uid 500); 16 Jul 2013 22:52:59 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 46127 invoked by uid 500); 16 Jul 2013 22:52:59 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 46119 invoked by uid 99); 16 Jul 2013 22:52:59 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Jul 2013 22:52:59 +0000 X-ASF-Spam-Status: No, hits=0.0 required=5.0 tests= X-Spam-Check-By: apache.org Received-SPF: error (athena.apache.org: local policy) Received: from [198.235.201.16] (HELO mx-3.northwestel.net) (198.235.201.16) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Jul 2013 22:52:54 +0000 X-ASG-Debug-ID: 1374015130-04700603df9fd10001-z14J5S Received: from [192.168.1.110] ([199.247.191.174]) by mx-3.northwestel.net with ESMTP id 6jjFlfo2onXmGZFx for ; Tue, 16 Jul 2013 15:52:10 -0700 (PDT) X-Barracuda-Envelope-From: stephan@bardubitzki.com X-Barracuda-Apparent-Source-IP: 199.247.191.174 Message-ID: <51E5CE9A.5040202@bardubitzki.com> Date: Tue, 16 Jul 2013 15:52:10 -0700 From: Stephan Bardubitzki User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130623 Thunderbird/17.0.7 MIME-Version: 1.0 To: user@couchdb.apache.org Subject: Re: startkey References: <51E47287.8070005@bardubitzki.com> <51E4A829.3040507@bardubitzki.com> <51E4ACAF.9040205@bardubitzki.com> <51E4C39B.1000705@bardubitzki.com> <51E58A49.6020404@bardubitzki.com> X-ASG-Orig-Subj: Re: startkey In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Barracuda-Connect: UNKNOWN[199.247.191.174] X-Barracuda-Start-Time: 1374015130 X-Barracuda-URL: http://198.235.201.16:8000/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at northwestel.net X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using per-user scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=6.8 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.2.136969 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-Virus-Checked: Checked by ClamAV on apache.org Hi Paul, unfortunately, I'm working only occasionally with CouchDB and hope this will change when I have more time to work on my own projects. Your advise was really helpful and appreciated. What I came up with is a map function like this: 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); } } } startkey: ["fr", id, 0]. endkey: ["fr", id, {}] gives me all the data needed either in the key or value argument and sorted as needed. Thanks for bearing with me, Stephan On 13-07-16 12:45 PM, Paul Davis wrote: > As the value (the second argument to emit). > > > On Tue, Jul 16, 2013 at 2:45 PM, Paul Davis wrote: > >> In that case I'd just emit the part of the doc for the language for each >> row. >> >> >> On Tue, Jul 16, 2013 at 1:00 PM, Stephan Bardubitzki < >> stephan@bardubitzki.com> wrote: >> >>> Got it, however, it is not quite what I was hoping to accomplish. >>> >>> The language object of the each doc has 12 languages and >>> include_docs=true will response all of them. What can I do to get all doc >>> properties but just the language 'fr' property, for example, to save on >>> data usage on mobile devices? >>> >>> >>> >>> On 13-07-15 09:00 PM, Paul Davis wrote: >>> >>>> Yes, the second example I gave should accomplish that. >>>> >>>> The {} is an empty JSON object which should sort higher than any value >>>> you >>>> emit assuming you're not emitting complicated objects which is not >>>> suggested due to surprising sort results. >>>> >>>> >>>> On Mon, Jul 15, 2013 at 10:52 PM, Stephan Bardubitzki < >>>> stephan@bardubitzki.com> wrote: >>>> >>>> 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 >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> **> >>>>>>>>>> **> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> 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 >>>>>> >>>>>> >>>>>> ------------------------------**-- >>>> 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 >