Riak simple SearchMapReduce throws IOException

2019-09-07 08:05发布

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条回答
仙女界的扛把子
2楼-- · 2019-09-07 08:18

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();
查看更多
登录 后发表回答