You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Mauro Fagnoni <ma...@gmail.com> on 2011/05/27 19:56:24 UTC

error during map function

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
-----------------------------------------------

Re: error during map function

Posted by Mauro Fagnoni <ma...@gmail.com>.
i solve my problem!

thanks all

2011/6/1 Patrick Barnes <mr...@gmail.com>

> Try typing 'js' from the server shell - it'll have been installed with
> couchdb, if it wasn't there already. It gives you an interactive js
> interpreter. Then, you can paste in your function; var map = function (doc)
> { .... } and it may tell you where the syntax error lies.
>
> Alternatively if you are using couchapp, you can test for syntax errors
> with 'js views/(view_name)/map.js'
>
> These methods may be more helpful than the errors that couchdb generates.
>
> Regards,
> -Patrick
>
>
>
> On 31/05/2011 6:29 AM, Mauro Fagnoni wrote:
>
>> 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<ma...@boutiquing.com>
>>
>>  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<ma...@boutiquing.com>  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<ma...@gmail.com>
>>>>
>>> wrote:
>>>
>>>> ok i see the problem but i have no a solution....could you give a hand?
>>>>>
>>>>> 2011/5/27 Mark Hahn<ma...@boutiquing.com>
>>>>>
>>>>>  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
-----------------------------------------------

Re: error during map function

Posted by Patrick Barnes <mr...@gmail.com>.
Try typing 'js' from the server shell - it'll have been installed with 
couchdb, if it wasn't there already. It gives you an interactive js 
interpreter. Then, you can paste in your function; var map = function 
(doc) { .... } and it may tell you where the syntax error lies.

Alternatively if you are using couchapp, you can test for syntax errors 
with 'js views/(view_name)/map.js'

These methods may be more helpful than the errors that couchdb generates.

Regards,
-Patrick


On 31/05/2011 6:29 AM, Mauro Fagnoni wrote:
> 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<ma...@boutiquing.com>
>
>> 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<ma...@boutiquing.com>  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<ma...@gmail.com>
>> wrote:
>>>> ok i see the problem but i have no a solution....could you give a hand?
>>>>
>>>> 2011/5/27 Mark Hahn<ma...@boutiquing.com>
>>>>
>>>>> 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
>>
>
>
>

Re: error during map function

Posted by Mauro Fagnoni <ma...@gmail.com>.
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 <ma...@boutiquing.com>

> 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 <ma...@boutiquing.com> 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 <ma...@gmail.com>
> wrote:
> >> ok i see the problem but i have no a solution....could you give a hand?
> >>
> >> 2011/5/27 Mark Hahn <ma...@boutiquing.com>
> >>
> >>> 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
-----------------------------------------------

Re: error during map function

Posted by MK <mk...@cognitivedissonance.ca>.
On Mon, 30 May 2011 12:37:51 +0200
Mauro Fagnoni <ma...@gmail.com> wrote:
> Hello, yes I noticed the if error but I can not use jslint because
> even with another
> query that I know are working me an error!

It's a basic axiom of programming that just because something seems to
work, does not mean it was done properly.

I doubt anyone is going to help you learn javascript here; there are
plenty of better places for that.  You will have to get your basic
syntax correct I think. ;)


-- 
"Enthusiasm is not the enemy of the intellect." (said of Irving Howe)
"The angel of history[...]is turned toward the past." (Walter Benjamin)


Re: error during map function

Posted by Mauro Fagnoni <ma...@gmail.com>.
Hello, yes I noticed the if error but I can not use jslint because
even with another
query that I know are working me an error! I, therefore, a bit of trouble.
you through the sql query you can help me out?

2011/5/29 Mark Hahn <ma...@boutiquing.com>

> 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 <ma...@boutiquing.com> 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 <ma...@gmail.com>
> wrote:
> >> ok i see the problem but i have no a solution....could you give a hand?
> >>
> >> 2011/5/27 Mark Hahn <ma...@boutiquing.com>
> >>
> >>> 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
-----------------------------------------------

Re: error during map function

Posted by Mark Hahn <ma...@boutiquing.com>.
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 <ma...@boutiquing.com> 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 <ma...@gmail.com> wrote:
>> ok i see the problem but i have no a solution....could you give a hand?
>>
>> 2011/5/27 Mark Hahn <ma...@boutiquing.com>
>>
>>> 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 <ma...@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

Re: error during map function

Posted by Mark Hahn <ma...@boutiquing.com>.
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 <ma...@gmail.com> wrote:
> ok i see the problem but i have no a solution....could you give a hand?
>
> 2011/5/27 Mark Hahn <ma...@boutiquing.com>
>
>> 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 <ma...@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

Re: error during map function

Posted by Mauro Fagnoni <ma...@gmail.com>.
ok i see the problem but i have no a solution....could you give a hand?

2011/5/27 Mark Hahn <ma...@boutiquing.com>

> 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 <ma...@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
-----------------------------------------------

Re: error during map function

Posted by Mark Hahn <ma...@boutiquing.com>.
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 <ma...@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