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 4C2076113 for ; Mon, 30 May 2011 20:30:48 +0000 (UTC) Received: (qmail 11873 invoked by uid 500); 30 May 2011 20:30:46 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 11846 invoked by uid 500); 30 May 2011 20:30:46 -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 11838 invoked by uid 99); 30 May 2011 20:30:46 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 30 May 2011 20:30:46 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of mauro.fagnoni@gmail.com designates 209.85.215.180 as permitted sender) Received: from [209.85.215.180] (HELO mail-ey0-f180.google.com) (209.85.215.180) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 30 May 2011 20:30:39 +0000 Received: by eyg24 with SMTP id 24so1912509eyg.11 for ; Mon, 30 May 2011 13:30:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type; bh=l9POkatV0ad9gtD0JMPia+PTQMeipkE5yY5fBXuhepA=; b=nZpVM1Y0C3wXBt3fBxuE585b42nEPNBLplMb7nxEWAZdj8GlLMTgVXg4cxTCdk388D gW8DjiW/6sMNa8uarqB5oZKmVn9IGxk++dg7gMBdknJooRfHT6TBKSWtdq4ZFF02Jugu 4p03cgGFzOKJIQk9mE9sBwymlm0S4nF4jDKLQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=KmiMIxJ4i7jpEtcrq5+YTiTE6RifbQL+qSC7FGNF8MwFE9ZhHa4oRFmi9D5hNUg+Lu 4TjA9terM1ETUvKBbM/roT0+/rQrH8P8ex/y4ivTw3sxQ0D01A1DPZU6Z4NosqHHtthk gc89pXPcS+e5rZ2XCp9+iUm6hWAgoTyO92Hlg= Received: by 10.213.26.83 with SMTP id d19mr1057120ebc.115.1306787419144; Mon, 30 May 2011 13:30:19 -0700 (PDT) MIME-Version: 1.0 Received: by 10.213.32.67 with HTTP; Mon, 30 May 2011 13:29:59 -0700 (PDT) In-Reply-To: References: From: Mauro Fagnoni Date: Mon, 30 May 2011 22:29:59 +0200 Message-ID: Subject: Re: error during map function To: user@couchdb.apache.org Content-Type: multipart/alternative; boundary=0015174bdb82ea41db04a4842799 X-Virus-Checked: Checked by ClamAV on apache.org --0015174bdb82ea41db04a4842799 Content-Type: text/plain; charset=ISO-8859-1 Hi, i've rewrite the query but i've also an error.... now whats the problem? regards { "map":" function(doc){ if ( ( (doc.partkey == doc.parteky) && (doc.brand == 'Brand#12') && ((doc.container == 'SM CASE') || (doc.container == 'SM BOX') || (doc.container == 'SM PACK') || (doc.container == 'SM PKG')) && (doc.quantity >= 1) && (doc.quantity <= 11) && ((doc.size > 1)&&(doc.size < 5)) && ((doc.shipmode == 'AIR') || (doc.shipmode == 'AIR REG'))&& (doc.shipinstruct == 'DELIVER IN PERSON') ) || ( (doc.partkey == doc.parteky)&& (doc.brand == 'Brand#23') && (doc.container == 'MED BAG') || (doc.container == 'MED BOX') || (doc.container == 'MED PKG') || (doc.container == 'MED PACK')) && (doc.quantity >= 10) && (doc.quantity <= 20) && ((doc.size > 1) && (doc.size < 10)) && ((doc.shipmode == 'AIR') || (doc.shipmode == 'AIR REG'))&& (doc.shipinstruct == 'DELIVER IN PERSON') ) || ( (doc.partkey == doc.parteky) && (doc.brand == 'Brand#34') && ((doc.container == 'LG CASE') || (doc.container == 'LG BOX') || (doc.container == 'LG PACK') || (doc.container == 'LG PKG')) && (doc.quantity >= 20) && (doc.quantity <= 30) && ((doc.size > 1) &&(doc.size < 15)) && ((doc.shipmode == 'AIR') || (doc.shipmode == 'AIR REG'))&& (doc.shipinstruct == 'DELIVER IN PERSON') ) ) emit (null, doc) }" , "reduce": " function(keys, values, rereduce){ var tags = {}; if(!rereduce){ for (var k in keys) { var extPrice = parseFloat(values[k].extendedprice); var disc1 = 1-parseFloat(values[k].discount); if(tags[key[k][0]]){ tags[keys[k][0]].revenue += extPrice * disc1; } else tags[keys[k][0]] = { 'revenue' : extPrice * disc1 }; } }else{ tags = values[0]; for(var v = 1; v < values.length; v++) { for(var t in values[v]) { if(tags[t]) { tags[t].revenue += values[v][t].revenue; } } } } return tags; }" } 2011/5/29 Mark Hahn > I just noticed you seem to have the idea that if looks like if{}. > This is not correct. It looks like if(){} in javascript. > > On Sun, May 29, 2011 at 11:59 AM, Mark Hahn wrote: > > Did you fix your syntax errors? You can use jslint to do that before > > I help you. You can ignore the jslint non-syntax errors. > > > > On Sun, May 29, 2011 at 7:40 AM, Mauro Fagnoni > wrote: > >> ok i see the problem but i have no a solution....could you give a hand? > >> > >> 2011/5/27 Mark Hahn > >> > >>> Use http://www.jslint.com/ to check your syntax. I changed the first > >>> part to read like this so it looked liked normal js instead of a big > >>> string ... > >>> > >>> x=function(doc){ > >>> if{((doc.partkey == doc.parteky) && > >>> > >>> It immediately saw the if { which is illegal. It found other errors as > >>> well. > >>> > >>> On Fri, May 27, 2011 at 10:56 AM, Mauro Fagnoni < > mauro.fagnoni@gmail.com> > >>> wrote: > >>> > Hi all i've to adjust this sql query into a valid .js query for > couchdb > >>> but > >>> > i've an error...someone help to find and solve my error??? > >>> > > >>> > Best regards > >>> > > >>> > .js query > >>> > > >>> > { > >>> > "map":"function(doc){ > >>> > if{((doc.partkey == doc.parteky) && > >>> > (doc.brand == 'Brand#12') && > >>> > (if {(doc.container == 'SM CASE') || (doc.container == 'SM > >>> BOX') > >>> > (doc.container == 'SM PACK') || (doc.container == 'SM PKG') > >>> > doc.container=true; > >>> > }else{doc.container=false;} > >>> > ) && > >>> > (doc.quantity >= 1) && > >>> > (doc.quantity <= 11) && > >>> > (doc.size > 1) && > >>> > (doc.size < 5) && > >>> > (if {(doc.shipmode == 'AIR')|| (doc.shipmode == 'AIR REG') > >>> > doc.shipmode = true; > >>> > }else {doc.shipmode = falese}&& > >>> > (doc.shipinstruct == 'DELIVER IN PERSON') > >>> > )} || > >>> > if{((doc.partkey == doc.parteky)&& > >>> > (doc.brand == 'Brand#23') && > >>> > (if {(doc.container == 'MED BAG') || (doc.container == > 'MED > >>> > BOX') (doc.container == 'MED PKG') || (doc.container == 'MED PACK') > >>> > doc.container=true; > >>> > }else{doc.container=false;} > >>> > ) && > >>> > (doc.quantity >= 10) && > >>> > (doc.quantity <= 20) && > >>> > (doc.size > 1) && > >>> > (doc.size < 10) && > >>> > (if {(doc.container == 'MED BAG') || (doc.container == > 'MED > >>> > BOX') (doc.container == 'MED PKG') || (doc.container == 'MED PACK') > >>> > doc.container=true; > >>> > }else{doc.container=false;} > >>> > ) && > >>> > (doc.shipinstruct == 'DELIVER IN PERSON') > >>> > )} || > >>> > if{((doc.partkey == doc.parteky) && > >>> > (doc.brand == 'Brand#34') && > >>> > (if {(doc.container == 'LG CASE') || > (doc.container == > >>> > 'LG BOX') (doc.container == 'LG PACK') || (doc.container == 'LG PKG') > >>> > doc.container=true; > >>> > }else{doc.container=false;} > >>> > ) && > >>> > (doc.quantity >= 20) && > >>> > (doc.quantity <= 30) && > >>> > (doc.size > 1) && > >>> > (doc.size < 15) && > >>> > (if {(doc.container == 'MED BAG') || (doc.container == > 'MED > >>> > BOX') (doc.container == 'MED PKG') || (doc.container == 'MED PACK') > >>> > doc.container=true; > >>> > }else{doc.container=false;} > >>> > ) && > >>> > (doc.shipinstruct == 'DELIVER IN PERSON') > >>> > )} > >>> > emit (null, doc) > >>> > }" , > >>> > "reduce": " > >>> > function(keys, values, rereduce){ > >>> > var tags = {}; > >>> > if(!rereduce){ > >>> > for (var k in keys) { > >>> > var extPrice = parseFloat(values[k].extendedprice); > >>> > var disc1 = 1-parseFloat(values[k].discount); > >>> > if(tags[key[k][0]]){ > >>> > tags[keys[k][0]].revenue += extPrice * disc1; > >>> > } > >>> > else tags[keys[k][0]] = { > >>> > 'revenue' : extPrice * disc1 > >>> > }; > >>> > } > >>> > }else{ > >>> > tags = values[0]; > >>> > for(var v = 1; v < values.length; v++) > >>> > { > >>> > for(var t in values[v]) > >>> > { > >>> > if(tags[t]) { > >>> > tags[t].revenue += values[v][t].revenue; > >>> > } > >>> > } > >>> > } > >>> > } > >>> > return tags; > >>> > }" > >>> > } > >>> > > >>> > > >>> > sql query > >>> > > >>> > SELECT > >>> > sum(L_EXTENDEDPRICE * (1 - L_DISCOUNT) ) as revenue > >>> > FROM > >>> > LINEITEM, > >>> > PART > >>> > WHERE > >>> > ( > >>> > P_PARTKEY = L_PARTKEY > >>> > and P_BRAND = 'Brand#12' > >>> > and P_CONTAINER in ( 'SM CASE', 'SM BOX', 'SM PACK', > 'SM > >>> > PKG') > >>> > and L_QUANTITY >= 1 and L_QUANTITY <= 1 + 10 > >>> > and P_SIZE between 1 and 5 > >>> > and L_SHIPMODE in ('AIR', 'AIR REG') > >>> > and L_SHIPINSTRUCT = 'DELIVER IN PERSON' > >>> > ) > >>> > or > >>> > ( > >>> > P_PARTKEY = L_PARTKEY > >>> > and P_BRAND = 'Brand#23' > >>> > and P_CONTAINER in ('MED BAG', 'MED BOX', 'MED PKG', > 'MED > >>> > PACK') > >>> > and L_QUANTITY >= 10 and L_QUANTITY <= 10 + 10 > >>> > and P_SIZE between 1 and 10 > >>> > and L_SHIPMODE in ('AIR', 'AIR REG') > >>> > and L_SHIPINSTRUCT = 'DELIVER IN PERSON' > >>> > ) > >>> > or > >>> > ( > >>> > P_PARTKEY = L_PARTKEY > >>> > and P_BRAND = 'Brand#34' > >>> > and P_CONTAINER in ( 'LG CASE', 'LG BOX', 'LG PACK', > 'LG > >>> > PKG') > >>> > and L_QUANTITY >= 20 and L_QUANTITY <= 20 + 10 > >>> > and P_SIZE between 1 and 15 > >>> > and L_SHIPMODE in ('AIR', 'AIR REG') > >>> > and L_SHIPINSTRUCT = 'DELIVER IN PERSON; > >>> > > >>> > > >>> > error log > >>> > > >>> > {"error":"compilation_error","reason":"Expression does not eval to a > >>> > function. ((new String(\"function(doc){\\n\\t\\tif{((doc.partkey == > >>> > doc.parteky) && \\n\\t\\t (doc.brand == 'Brand#12') &&\\n\\t\\t > (if > >>> > {(doc.container == 'SM CASE') || (doc.container == 'SM BOX') > >>> (doc.container > >>> > == 'SM PACK') || (doc.container == 'SM PKG')\\n\\t\\t > >>> > > \\tdoc.container=true;\\n\\t\\t\\t}else{doc.container=false;}\\n\\t\\t > >>> ) > >>> > &&\\n\\t\\t (doc.quantity >= 1) &&\\n\\t\\t (doc.quantity <= 11) > >>> > &&\\n\\t\\t (doc.size > 1) &&\\n\\t\\t (doc.size < 5) &&\\n\\t\\t > >>> (if > >>> > {(doc.shipmode == 'AIR')|| (doc.shipmode == 'AIR > >>> > REG')\\n\\t\\t\\t\\t\\tdoc.shipmode = true;\\n\\t\\t\\t\\t}else > >>> > {doc.shipmode = falese}&&\\n\\t\\t (doc.shipinstruct == 'DELIVER IN > >>> > PERSON')\\n\\t\\t)} ||\\n\\t\\t if{((doc.partkey == doc.parteky)&& > >>> > \\n\\t\\t \\t(doc.brand == 'Brand#23') &&\\n\\t\\t \\t(if > >>> > {(doc.container == 'MED BAG') || (doc.container == 'MED BOX') > >>> (doc.container > >>> > == 'MED PKG') || (doc.container == 'MED PACK')\\n\\t\\t \\t > >>> > doc.container=true;\\n\\t\\t\\t > }else{doc.container=false;}\\n\\t\\t > >>> > \\t) &&\\n\\t\\t \\t(doc.quantity >= 10) &&\\n\\t\\t > \\t(doc.quantity > >>> <= > >>> > 20) &&\\n\\t\\t \\t(doc.size > 1) &&\\n\\t\\t \\t(doc.size < 10) > >>> > &&\\n\\t\\t \\t(if {(doc.container == 'MED BAG') || (doc.container > == > >>> 'MED > >>> > BOX') (doc.container == 'MED PKG') || (doc.container == 'MED > >>> > PACK')\\n\\t\\t \\t doc.container=true;\\n\\t\\t\\t > >>> > }else{doc.container=false;}\\n\\t\\t \\t) &&\\n\\t\\t > >>> > \\t(doc.shipinstruct == 'DELIVER IN PERSON')\\n\\t\\t)} > >>> > ||\\n\\t\\tif{((doc.partkey == doc.parteky) && \\n\\t\\t > \\t(doc.brand > >>> == > >>> > 'Brand#34') &&\\n \\t (if {(doc.container == 'LG CASE') > || > >>> > (doc.container == 'LG BOX') (doc.container == 'LG PACK') || > >>> (doc.container > >>> > == 'LG PKG')\\n\\t\\t \\t\\tdoc.container=true;\\n\\t\\t\\t > >>> > }else{doc.container=false;}\\n\\t\\t \\t) > &&\\n\\t\\t\\t(doc.quantity > >>> >= > >>> > 20) &&\\n\\t\\t \\t(doc.quantity <= 30) &&\\n\\t\\t \\t(doc.size > > 1) > >>> > &&\\n\\t\\t \\t(doc.size < 15) &&\\n\\t\\t \\t(if {(doc.container > == > >>> 'MED > >>> > BAG') || (doc.container == 'MED BOX') (doc.container == 'MED PKG') || > >>> > (doc.container == 'MED PACK')\\n\\t\\t \\t > >>> > doc.container=true;\\n\\t\\t\\t > }else{doc.container=false;}\\n\\t\\t > >>> > \\t) &&\\n\\t\\t \\t(doc.shipinstruct == 'DELIVER IN > >>> > PERSON')\\n\\t\\t)}\\n\\temit (null, doc)\\n\\t}\")))"} > >>> > > >>> > -- ----------------------------------------------- > >>> > [-------WHOAMI------] Mauro Fagnoni > >>> > [----------ICQ#---------] 279572903 > >>> > [--------MSNID--------] maurofagnoni@yahoo.it > >>> > [--YAHOOMSNID--] maurofagnoni@gmail.com > >>> > [--GOOGLETALK--] mauro.fagnoni@gmail.com > >>> > [-GOOGLEWAVE-] mauro.fagnoni@googlewave.com > >>> > [------JABBER-------] mauro.fagnoni@gmail.com > >>> > [------SKYPE--------] mauro.fagnoni > >>> > [-----LinuxUser#----] 346345 > >>> > [----------Blog---------] http://kingmauro.wordpress.com > >>> > ----------------------------------------------- > >>> > > >>> > >>> > >>> > >>> -- > >>> Mark Hahn > >>> Website Manager > >>> mark@boutiquing.com > >>> 949-229-1012 > >>> > >> > >> > >> > >> -- > >> ----------------------------------------------- > >> [-------WHOAMI------] Mauro Fagnoni > >> [----------ICQ#---------] 279572903 > >> [--------MSNID--------] maurofagnoni@yahoo.it > >> [--YAHOOMSNID--] maurofagnoni@gmail.com > >> [--GOOGLETALK--] mauro.fagnoni@gmail.com > >> [-GOOGLEWAVE-] mauro.fagnoni@googlewave.com > >> [------JABBER-------] mauro.fagnoni@gmail.com > >> [------SKYPE--------] mauro.fagnoni > >> [-----LinuxUser#----] 346345 > >> [----------Blog---------] http://kingmauro.wordpress.com > >> ----------------------------------------------- > >> > > > > > > > > -- > > Mark Hahn > > Website Manager > > mark@boutiquing.com > > 949-229-1012 > > > > > > -- > Mark Hahn > Website Manager > mark@boutiquing.com > 949-229-1012 > -- ----------------------------------------------- [-------WHOAMI------] Mauro Fagnoni [----------ICQ#---------] 279572903 [--------MSNID--------] maurofagnoni@yahoo.it [--YAHOOMSNID--] maurofagnoni@gmail.com [--GOOGLETALK--] mauro.fagnoni@gmail.com [-GOOGLEWAVE-] mauro.fagnoni@googlewave.com [------JABBER-------] mauro.fagnoni@gmail.com [------SKYPE--------] mauro.fagnoni [-----LinuxUser#----] 346345 [----------Blog---------] http://kingmauro.wordpress.com ----------------------------------------------- --0015174bdb82ea41db04a4842799--