I'll preface this by saying I've never used this feature....<br><br>rs_extractfun should be set to one of the values defined in the Other Encodings section (<a href="http://wiki.basho.com/Riak-Search---Indexing-and-Querying-Riak-KV-Data.html">http://wiki.basho.com/Riak-Search---Indexing-and-Querying-Riak-KV-Data.html</a>).  In your case, {jsanon, "function(a,b){return{\"user\":\"gpascale\", \"name\":\"greg\"};}"}<br>
<br>Hope that helps,<br><br>Andrew<br><br><div class="gmail_quote">On Sat, May 21, 2011 at 7:48 PM, Greg Pascale <span dir="ltr"><<a href="mailto:greg@clipboard.com">greg@clipboard.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I've been banging my head against the wall trying to get a javascript custom extractor working. Here is the simplest example I could come up with to reproduce the error.<div><div><br></div><div><div><b>curl -v -X PUT -H "Content-Type: application/json" <a href="http://localhost:8098/riak/test" target="_blank">http://localhost:8098/riak/test</a> -d @data</b></div>

</div><div><br></div><div>where <b>@data</b> is a file that looks like</div><div><br></div><div><div><b>{"props":</b></div><div><b> {"rs_extractfun":</b></div><div><b>  {"language" : "javascript", </b></div>

<div><b>   "source" : "function(a,b){return{\"user\":\"gpascale\", \"name\":\"greg\"};}"</b></div><div><b>  }</b></div><div><b> }</b></div><div><b>}</b></div></div>

<div><b><br></b></div><div>This completes successfully, and I can verify it by looking at the properties of the "test" bucket.</div><div><br></div><div><b>{"props":{"allow_mult":true,"basic_quorum":true,"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,"name":"test","notfound_ok":false,"old_vclock":86400,"postcommit":[],"pr":0,"precommit":[{"mod":"riak_search_kv_hook","fun":"precommit"}],"pw":0,"r":"quorum","rs_extractfun":{"language":"javascript","source":"function(a,b){return{\"user\":\"gpascale\", \"name\":\"greg\"};}"},"rw":"quorum","small_vclock":10,"w":"quorum","young_vclock":20}}</b></div>

<div><br></div><div>However, when I try to insert something into the bucket, I get an error</div><div><br></div><div><b>curl -X PUT <a href="http://localhost:8098/riak/test/test1" target="_blank">http://localhost:8098/riak/test/test1</a> -d "Hello, world!"</b></div>

<div><br></div><div><div><b>{error,badarg,</b></div><div><b>        [{erlang,iolist_to_binary,</b></div><div><b>             [{hook_crashed,</b></div><div><b>                  {riak_search_kv_hook,precommit,exit,</b></div>

<div><b>                      {noproc,</b></div><div><b>                          {gen_server,call,</b></div><div><b>                              [riak_search_js_extract,reserve_vm,</b></div><div><b>                               infinity]}}}}]},</b></div>

<div><b>         {wrq,append_to_response_body,2},</b></div><div><b>         {riak_kv_wm_raw,accept_doc_body,2},</b></div><div><b>         {webmachine_resource,resource_call,3},</b></div><div><b>         {webmachine_resource,do,3},</b></div>

<div><b>         {webmachine_decision_core,resource_call,1},</b></div><div><b>         {webmachine_decision_core,accept_helper,0},</b></div><div><b>         {webmachine_decision_core,decision,1}]}}</b></div></div></div><div>

<b><br></b></div><div>It doesn't matter if the thing I insert is a string, as above, or real json object that matches my schema - the error is the same. Any ideas what might be going on here?</div><div><br></div><div>

Thanks,</div><div>-Greg</div>
<br>_______________________________________________<br>
riak-users mailing list<br>
<a href="mailto:riak-users@lists.basho.com">riak-users@lists.basho.com</a><br>
<a href="http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com" target="_blank">http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com</a><br>
<br></blockquote></div><br>