Hi,

I am trying to run the following mapreduce query across my cluster:

# curl -XPOST http://10.179.229.209:8098/mapred -H "Content-Type:
application/json" -d '{"inputs":"tweets",
"query":[{"map":{"language":"javascript", "source":"function(value,
keyData, arg) {t = JSON.parse(value.values[0].data)[0]; if ((new Date
- new Date(t.created_at)) / 1000 > 2592000) return [t.id]; else return
[]}", "keep":true}}]}'
{"lineno":466,"message":"SyntaxError: syntax error","source":"()"}

The riak logs only have the following to report:

==> /var/log/riak/crash.log <==
2013-09-24 05:42:51 =ERROR REPORT====
webmachine error: path="/mapred"
"Internal Server Error"

==> /var/log/riak/console.log <==
2013-09-24 05:42:51.272 [error] <0.20367.1441> Webmachine error at
path "/mapred" : "Internal Server Error"

==> /var/log/riak/error.log <==
2013-09-24 05:42:51.272 [error] <0.20367.1441> Webmachine error at
path "/mapred" : "Internal Server Error"

Is there any way to get some more info on this to debug it further?

I have tried using ejsLog() (from
http://docs.basho.com/riak/1.3.2/references/appendices/MapReduce-Implementation/#Debugging-Javascript-Map-Reduce-Phases)
to inspect the data in the function body but that simply gives me:

# curl -XPOST http://10.179.229.209:8098/mapred -H "Content-Type:
application/json" -d '{"inputs":"tweets",
"query":[{"map":{"language":"javascript", "source":"function(value,
keyData, arg) {t = JSON.parse(value.values[0].data)[0];
ejsLog('/tmp/map_reduce.log', JSON.stringify(t)); if ((new Date - new
Date(t.created_at)) / 1000 > 2592000) return [t.id]; else return []}",
"keep":true}}]}'
{"lineno":1,"message":"SyntaxError: invalid flag after regular
expression","source":"JSON.stringify(function(value, keyData, arg) {t
= JSON.parse(value.values[0].data)[0]; ejsLog(/tmp/map_reduce.log,
JSON.stringify(t)); if ((new Date - new Date(t.created_at)) / 1000 >
2592000) return [t.id]; else return
[]}({\"bucket\":\"tweets\",\"key\":\"37456"}

I have also tried checking for already deleted documents in case that
was what tripping things up but adding a check in for the
X-Riak-Deleted header also results in an error:

# curl -XPOST http://10.179.229.209:8098/mapred -H "Content-Type:
application/json" -d '{"inputs":"tweets",
"query":[{"map":{"language":"javascript", "source":"function(value,
keyData, arg) {if (value.values[0].metadata['X-Riak-Deleted'] ==
'true') return []; t = JSON.parse(value.values[0].data)[0]; if ((new
Date - new Date(t.created_at)) / 1000 > 2592000) return [t.id]; else
return []}", "keep":true}}]}'
{"lineno":1,"message":"ReferenceError: X is not defined","source":"unknown"}


-- 
Ciao

Charl

"I will either find a way, or make one." -- Hannibal

_______________________________________________
riak-users mailing list
riak-users@lists.basho.com
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

Reply via email to