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 33BCF1033A for ; Tue, 16 Jul 2013 04:02:02 +0000 (UTC) Received: (qmail 86649 invoked by uid 500); 16 Jul 2013 04:02:00 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 86479 invoked by uid 500); 16 Jul 2013 04:01: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 86471 invoked by uid 99); 16 Jul 2013 04:01:59 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Jul 2013 04:01:59 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of paul.joseph.davis@gmail.com designates 209.85.219.50 as permitted sender) Received: from [209.85.219.50] (HELO mail-oa0-f50.google.com) (209.85.219.50) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Jul 2013 04:01:53 +0000 Received: by mail-oa0-f50.google.com with SMTP id k7so255964oag.9 for ; Mon, 15 Jul 2013 21:01:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=FDqW5ajKlADeHk/wakhCZGTHSOdkHFZqx4u99JibLp4=; b=HRmdIshNibjGwxyOo0b9ZAY7wJ5WTVi2j/g0vjPcXQY/an41hhe4qJqI2JRAu3svj0 HATe5TRJngw5C9GGidgWwR2xH58Fz3AbfPr4Q0M795FEyf2cYI1y1rNtYbrDHrcQ5TZf FspMpurxZmZgIcZMthH5Iyzr2tDXdj5g+q92dRtdkTCRAK4fMCvQaVAMzG3vPxgm+dFT g7biD5GpUYOgVYRuVGY7CsbAibUQvc8rIHgZE0BBH972rmLGUuCpsrh1swt4t9GlGjWG 7Fs7VCo+BJEzT7YIdKsIuaw1ww0IaDTrN/1XlJJlW6OWPaG0LfxwLf/4cLecOBOrElYK JkqQ== X-Received: by 10.60.45.103 with SMTP id l7mr45649142oem.25.1373947292001; Mon, 15 Jul 2013 21:01:32 -0700 (PDT) MIME-Version: 1.0 Received: by 10.60.121.104 with HTTP; Mon, 15 Jul 2013 21:00:51 -0700 (PDT) In-Reply-To: <51E4C39B.1000705@bardubitzki.com> References: <51E47287.8070005@bardubitzki.com> <51E4A829.3040507@bardubitzki.com> <51E4ACAF.9040205@bardubitzki.com> <51E4C39B.1000705@bardubitzki.com> From: Paul Davis Date: Mon, 15 Jul 2013 23:00:51 -0500 Message-ID: Subject: Re: startkey To: "user@couchdb.apache.org" Content-Type: multipart/alternative; boundary=089e015369ee47b00204e1990843 X-Virus-Checked: Checked by ClamAV on apache.org --089e015369ee47b00204e1990843 Content-Type: text/plain; charset=ISO-8859-1 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 >> >**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 >> >> > --089e015369ee47b00204e1990843--