Riak simple SearchMapReduce throws IOException

ⅰ亾dé卋堺 提交于 2019-12-24 23:37:33

问题


I am trying to fetch Raik objects using simple filters. I have enabled search on the bucket before storing objects to it, and I try the following:

MapReduceResult result = riakClient. mapReduce("serviceProvider", "name:oved1"). addMapPhase(new NamedJSFunction("Riak.mapValuesJson"), true).execute();

I get this exception:

com.basho.riak.client.RiakException: java.io.IOException: {"error":"map_reduce_error"} at com.basho.riak.client.query.MapReduce.execute(MapReduce.java:80) at com.att.cso.omss.datastore.riak.controllers.RiakBaseController.getAllServiceProvider(RiakBaseController.java:339) at com.att.cso.omss.datastore.riak.App.serviceProviderTests(App.java:64) at com.att.cso.omss.datastore.riak.App.main(App.java:38) Caused by: java.io.IOException: {"error":"map_reduce_error"} at com.basho.riak.client.raw.http.ConversionUtil.convert(ConversionUtil.java:588) at com.basho.riak.client.raw.http.HTTPClientAdapter.mapReduce(HTTPClientAdapter.java:386) at com.basho.riak.client.query.MapReduce.execute(MapReduce.java:78) ... 3 more

any idea what am I missing?


回答1:


Was able to fix this issue...

apparently you need to do 2 things prior to storing objects that need to be searched in the future:

  1. Enabled search in app.config (/etc/riak):

{riak_search, [{enabled, true}]}

  1. Enable search on the bucket:

Bucket bucket = riakClient.createBucket(bucketName).enableForSearch().execute();

After doing that, this returns values:

      MapReduceResult result = riakClient.
            mapReduce(bucketName, "name:9"). 
            addMapPhase(new NamedJSFunction("Riak.mapValuesJson"), true).
            execute();


来源:https://stackoverflow.com/questions/11921245/riak-simple-searchmapreduce-throws-ioexception

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!