Date format for Riak Search and its JSON output

Nicolas Fouché nicolas at silentale.com
Thu Nov 4 12:17:15 EDT 2010


Hi,

I can't find the right format for dates in Riak Search, for fields
suffixed with "_dt". I tried rfc822 (e.g. "Thu, 04 Nov 2010 16:02:59
-0000"), and xmlschema/iso8601 (e.g. "2010-11-04T16:07:43Z"), but I
get an {unhandled_type,date} error when requesting my data in JSON. No
problem with XML.

Here are the HTTP queries to reproduce the error:

# Get the bucket props

GET http://127.0.0.1:8098/riak/models?keys=false
	{"Accept"=>"multipart/mixed, application/json;q=0.7, */*;q=0.5",
"X-Riak-ClientId"=>"A1Q9KQ=="}

# Set the pre-commit search hook

PUT http://127.0.0.1:8098/riak/models
	{"Accept"=>"multipart/mixed, application/json;q=0.7, */*;q=0.5",
"X-Riak-ClientId"=>"A1Q9KQ==", "Content-Type"=>"application/json"}
	{"props":{"precommit":[{"mod":"riak_search_kv_hook","fun":"precommit"}]}}

# Check if there are any keys to delete

GET http://127.0.0.1:8098/riak/models?props=false&keys=true
	{"Accept"=>"multipart/mixed, application/json;q=0.7, */*;q=0.5",
"X-Riak-ClientId"=>"A1Q9KQ=="}

# Post a JSON document with a date in rfc822 (day-of-week, DD
month-name CCYY hh:mm:ss zone)

POST http://127.0.0.1:8098/riak/models?returnbody=true
	{"Accept"=>"multipart/mixed, application/json;q=0.7, */*;q=0.5",
"X-Riak-ClientId"=>"A1Q9KQ==", "Content-Type"=>"application/json"}
	{"time_dt":"Thu, 04 Nov 2010 16:02:59 -0000","value":"a value like
any other value","_type":"Model"}

# Search for the object and request a JSON ouput => KO

GET http://127.0.0.1:8098/solr/models/select?q=value%3Aother&wt=json
	{"Accept"=>"multipart/mixed, application/json;q=0.7, */*;q=0.5",
"X-Riak-ClientId"=>"A1Q9KQ=="}

  <html><head><title>500 Internal Server
Error</title></head><body><h1>Internal Server Error</h1>The server
encountered an error while processing this
request:<br><pre>{error,{throw,{unhandled_type,date},
                [{riak_solr_output,convert_type,2},
                 {riak_indexed_doc,'-to_mochijson2/2-lc$^0/1-0-',2},
                 {riak_indexed_doc,'-to_mochijson2/2-lc$^0/1-0-',2},
                 {riak_indexed_doc,to_mochijson2,2},
                 {riak_solr_output,'-json_response/7-lc$^0/1-0-',2},
                 {riak_solr_output,json_response,7},
                 {riak_solr_searcher_wm,to_json,2},

{webmachine_resource,resource_call,3}]}}</pre><P><HR><ADDRESS>mochiweb+webmachine
web server</ADDRESS></body></html>[nfo@
17:13:46]~/Code/tests/riak/search

# Search for the object and request a XML ouput => OK

GET http://127.0.0.1:8098/solr/models/select?q=value%3Aother&wt=xml

  <?xml version="1.0" encoding="UTF-8"?>
  <response>
    <lst name="responseHeader">
      <int name="status">0</int>
      <int name="QTime">1</int>
      <lst name="params">
        <str name="indent">on</str>
        <str name="start">0</str>
        <str name="q">value:other</str>
        <str name="q.op">or</str>
        <str name="df">value</str>
        <str name="wt">standard</str>
        <str name="version">1.1</str>
        <str name="rows">2</str>
      </lst>
    </lst>
    <result name="response" numFound="1" start="0" maxScore="0.500000">
      <doc>
        <str name="id">67rGKh9XJSZBsPeet0LpdCzi1hz
        </str>
        <str name="_type">Model
        </str>
        <date name="time_dt">Thu, 04 Nov 2010 16:02:59 -0000
        </date>
        <str name="value">a value like any other value
        </str>
      </doc>
    </result>
  </response>

-- Nicolas




More information about the riak-users mailing list