我无法使 key_filter 与 string_to_int 转换一起工作,总是得到状态代码 500。
我的对象结构如下:
{ "style": "double", "capacity": 6 }
我的地图功能:
var client = require('riak-js')
.getClient({host: "localhost", port: "10018"}),
bucket = 'rooms';
client.mapreduce
.add({
bucket: bucket,
key_filters: [["string_to_int"], ["and", [["greater_than", 1000]], [["less_than", 3000]]]]
})
.map('Riak.mapValuesJson')
.run(function(err, data){
if (err) {
console.log(JSON.stringify(err));
} else {
console.log(JSON.stringify(data));
}
});
回复:
{ "message": "[object Object]", "statusCode": 500 }
附言
- 里亚克 1.4.7
- 二郎 R15B01
- nodejs v0.10.25
- riak-js 0.10.2
更新 这里是我对密钥和响应的请求:
卷曲http://mydomain.com:10018/riak/rooms?keys=true
{"props":{"name":"rooms","allow_mult":false,"basic_quorum":false,"big_vclock":50,"chash_keyfun": {"mod":"riak_core_util","fun":" chash_std_keyfun"},"dw":"quorum","last_write_wins":false,"linkfun":{"mod":"riak_kv_wm_link_walker","fun":"mapreduce_linkfun"},"n_val":3,"notfound_ok": true,"old_vclock":86400,"postcommit":[],"pr":0,"precommit":[],"pw":0,"r":"quorum","rw":"quorum", "small_vclock":50,"w":"quorum","young_vclock":20},"keys":["6774","2205","6515","3812","2164","8677","3637","8701","2868","7249","3118","9781","4217","8432","4250","7551","7672" ,"8736","7933"...
更新 2 我确实请求 curl:
curl -v -X POST -H "Content-Type: application/json" http://mydomain.com:10018/mapred -d '{"inputs": {"bucket":"rooms","key_filters":[ ["string_to_int"],["and",[["greater_than",1000]],[["less_than",3000]]]]}, "查询":[{"map":{"language":" javascript","name":"Riak.mapValuesJson"}}]}'
并得到结果:
{ "phase":"listkeys", "error":"function_clause",
"input":"{cover,[{1392993748081016843912887106182707253109560705024, 1392993748081016843912887106182707253109560705024]}],
{<<\"rooms\">>,[{riak_kv_mapred_filters,string_to_int,[]},{riak_kv_mapred_filters,logical_and,[[[<<\"greater_than\">>,1000]],[[<<\"less_than\">>,3000]]]}]}}",
"type":"error","stack":"[{riak_kv_pipe_listkeys,keysend,[error,{worker_crash,{badarg,[{erlang,list_to_integer,
[\"5Ll5Gl3L61JX2mxYUvht6OMca4d\"],[]},{riak_kv_mapred_filters,'-string_to_int/1-fun-0-',1,
[{file,\"src/riak_kv_mapred_filters.erl\"},
{line,84}]},
{lists,foldl,3,[{file,\"lists.erl\"},{line,1197}]},
{riak_kv_coverage_filter,'-compose/2-fun-1-',2,[{file,\"src/riak_kv_coverage_filter.erl\"},{line,137}]},
{riak_kv_vnode,'-fold_fun/3-fun-3-',5,[{file,\"src/riak_kv_vnode.erl\"},{line,1342}]},
{bitcask_nifs,keydir_fold_cont,4,...},...]},...},...],...},...]"
}