Storing as erlang-binary/term, reading as json.

Fyodor Yarochkin fyodor.y at
Thu Aug 11 12:03:39 EDT 2011

 I am probably missing something obvious, but I've been playing with
it for a couple of days, still can't figure out the consistency and I
am still a little lost with riak source code so I thought I'd drop a
line here:

I am experimenting with querying riak data data in different mime
formats from riak cluster. So for the tests, I am having a piece of
erlang code, which uses riak-erlang-client, writes some data into riak
as erlang-binary.

    Object = riakc_obj:new(<<"test">>,
test_util:get_datekey(),{struct, [{field, Value}]}),
    riakc_pb_socket:put(RiakPid, Object),

Now I am trying to make the data to be accessible to non-erlang
clients so the node.js code (for example) would be able to read it as

My understanding is that I should be able to specify that I want
json-formatted data back by adding 'Accept: application/json' header
(per example here

However I am getting HTTP 406 whenever I am trying to query anything
but erlang-binary:

srv# curl -i 'http://localhost:8098/riak/test/2011811234248'
HTTP/1.1 200 OK
X-Riak-Vclock: a85hYGBgymDKBVIsLC6FEzKYEhnzWBkyincc54MIszUnMfB8v4wskQUA
Vary: Accept-Encoding
Server: MochiWeb/1.1 WebMachine/1.7.3 (participate in the frantic)
Link: </riak/test>; rel="up"
Last-Modified: Thu, 11 Aug 2011 15:38:16 GMT
ETag: "6iDf0EKIk76L1KxlXoSB29"
Date: Thu, 11 Aug 2011 15:33:41 GMT
Content-Type: application/x-erlang-binary
Content-Length: 565

However, for application/json

srv# curl -H 'Accept: application/json' -i
HTTP/1.1 406 Not Acceptable
Server: MochiWeb/1.1 WebMachine/1.7.3 (participate in the frantic)
Date: Thu, 11 Aug 2011 15:34:12 GMT
Content-Length: 0

So, should I store the data as 'json' (json string converted to erlang
binary) in order to have some uniform data format accessible to erlang
and non-erlang clients?
also, how do map-reduce functions work in this case, do they have to
be strictly erlang in the case of having x-erlang-binary, or the data
could be converted to json for javascript?


More information about the riak-users mailing list