Error on the website example

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Error on the website example

Tyler Smart
Hi guys

I was trying to run the example post on an EC2 instance today, and got an error in the JS you were running

When I put in this query:


$ curl -X POST -H "content-type: application/json" http://localhost:8098/mapred --data @-
{"inputs":[["alice","p1"],["alice","p2"],["alice","p5"]],"query":[{"map":{"language":"javascript","source":"function(v) { var m = v.values[0].data.toLowerCase().match('\\\\w*','g'); var r = []; for(var i in m) if (m[i] != '') { var o = {}; o[m[i]] = 1; r.push(o); } return r; }"}},{"reduce":{"language":"javascript","source":"function(v) { var r = {}; for (var i in v) { for(var w in v[i]) { if (w in r) r[w] += v[i][w]; else r[w] = v[i][w]; } } return [r]; }"}}]}
^D

on this page, http://wiki.basho.com/display/RIAK/MapReduce


I get this response

{"lineno":1,"message":"TypeError: v.values is undefined","source":"unknown"}

Sincerely,
Tyler

_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
Reply | Threaded
Open this post in threaded view
|

Re: Error on the website example

Grant Schofield
This may be caused by inputing the keys incorrectly when you loaded the data,  you may want to check that all of the keys exist and run your query again. The quickest way to work around it would be to just specify the bucket and no keys which will map/reduce over every key:
curl -X POST -H "content-type: application/json" http://192.168.52.129:8098/mapred --data @-
{"inputs": "alice","query":[{"map":{"language":"javascript","source":"function(v) { var m = v.values[0].data.toLowerCase().match('\\\\w*','g'); var r = []; for(var i in m) if (m[i] != '') { var o = {}; o[m[i]] = 1; r.push(o); } return r; }"}},{"reduce":{"language":"javascript","source":"function(v) { var r = {}; for (var i in v) { for(var w in v[i]) { if (w in r) r[w] += v[i][w]; else r[w] = v[i][w]; } } return [r]; }"}}]}
^D

Get back to us if you have any more issues with the example.

Grant Schofield
Developer Advocate
Basho Technologies, Inc.



On Mar 31, 2010, at 1:56 PM, Tyler Smart wrote:

Hi guys

I was trying to run the example post on an EC2 instance today, and got an error in the JS you were running

When I put in this query:

$ curl -X POST -H "content-type: application/json" http://localhost:8098/mapred --data @-
{"inputs":[["alice","p1"],["alice","p2"],["alice","p5"]],"query":[{"map":{"language":"javascript","source":"function(v) { var m = v.values[0].data.toLowerCase().match('\\\\w*','g'); var r = []; for(var i in m) if (m[i] != '') { var o = {}; o[m[i]] = 1; r.push(o); } return r; }"}},{"reduce":{"language":"javascript","source":"function(v) { var r = {}; for (var i in v) { for(var w in v[i]) { if (w in r) r[w] += v[i][w]; else r[w] = v[i][w]; } } return [r]; }"}}]}
^D

on this page, http://wiki.basho.com/display/RIAK/MapReduce


I get this response

{"lineno":1,"message":"TypeError: v.values is undefined","source":"unknown"}

Sincerely,
Tyler
_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com


_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com