HTTP MapReduce

MapReduce is a generic way to query Riak by specifying inputs and constructing a set of map, reduce, and link phases through which data will flow.


POST /mapred

Important headers: * Content-Type - must always be application/json. The format of the request body is described in detail on the MapReduce page.

Optional query parameters: * chunked - when set to true, results will be returned as they are received in multipart/mixed format using chunked-encoding.

+This request must include an entity (body), which is the JSON form of the MapReduce query.+


Normal status codes: * 200 OK

Typical error codes: * 400 Bad Request - if an invalid job is submitted. * 500 Internal Server Error - if there was an error in processing a map or reduce function * 503 Service Unavailable - if the job timed out before it could complete

Important headers: * Content-Type - application/json when chunked is not true, otherwise multipart/mixed with application/json sections.


$ curl -v -d '{"inputs":"test", "query":[{"link":{"bucket":"test"}},{"map":{"language":"javascript","name":"Riak.mapValuesJson"}}]}' -H "Content-Type: application/json"
* About to connect() to port 8098 (#0)
*   Trying connected
* Connected to ( port 8098 (#0)
> POST /mapred HTTP/1.1
> User-Agent: curl/7.19.4 (universal-apple-darwin10.0) libcurl/7.19.4 OpenSSL/0.9.8l zlib/1.2.3
> Host:
> Accept: */*
> Content-Type: application/json
> Content-Length: 117
< HTTP/1.1 200 OK
< Server: MochiWeb/1.1 WebMachine/1.9.0 (participate in the frantic)
< Date: Fri, 30 Sep 2011 15:24:35 GMT
< Content-Type: application/json
< Content-Length: 30
* Connection #0 to host left intact
* Closing connection #0