scala - Riak simple query doesn't return data - Riak Java Client -


the below snippet rather simple, , looking @ others examples should have worked

val result = client.mapreduce("some-users","firstname:scala").execute println(result.getresultraw)// prints "[]" 

but, record firstname:scala there in bucket.

running code,

val result = client.mapreduce("some-users").execute ,it returns key of record 

and when check data using rest client app, in browser using

http://localhost:8098//riak/some-users/key 

i required json data, of course has "firstname" : "scala", why isn't first snippet returning values, have turned 'riak_search' on, though using riak java client scala based app should not posing problems.

does have idea why snippet isn't working should. riak version 1.3.2 , riak java client :- 1.1.4

since you've got riak , running, need search going:

first make sure have search enabled in app.config file on every node in cluster:

{riak_search, [                {enabled, true}               ]}, 

if changed need restart riak take effect.

then command line, install search hook on bucket want indexed:

# search-cmd install testbucket  :: installing riak search <--> kv hook on bucket 'testbucket'. 

at point if there data in bucket, not indexed. need re-put pre-existing data want indexed.

for quick demonstration, created 3 keys, creatively named 1,2, , 3; each containing simple json object:

curl localhost:8098/buckets/testbucket/keys/1 -h "content-type: application/json" -xput \  -d '{"firstname":"tom", "color":"red"}' curl localhost:8098/buckets/testbucket/keys/2 -h "content-type: application/json" -xput \  -d '{"firstname":"dick", "color":"green"}' curl localhost:8098/buckets/testbucket/keys/3 -h "content-type: application/json" -xput \  -d '{"firstname":"harry", "color":"blue"}' 

i can query search find keys:

# curl http://localhost:8098/solr/testbucket/select\?q=firstname:harry          <?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">firstname:harry</str>       <str name="q.op">or</str>       <str name="filter"></str>       <str name="df">value</str>       <str name="wt">standard</str>       <str name="version">1.1</str>       <str name="rows">1</str>     </lst>   </lst>   <result name="response" numfound="1" start="0" maxscore="0.353553">     <doc>       <str name="id">3       </str>       <str name="color">blue       </str>       <str name="firstname">harry       </str>     </doc>   </result> </response>  # curl http://localhost:8098/solr/testbucket/select\?q=color:red%20or%20firstname:harry <?xml version="1.0" encoding="utf-8"?> <response>   <lst name="responseheader">     <int name="status">0</int>     <int name="qtime">2</int>     <lst name="params">       <str name="indent">on</str>       <str name="start">0</str>       <str name="q">color:red or firstname:harry</str>       <str name="q.op">or</str>       <str name="filter"></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="2" start="0" maxscore="0.143844">     <doc>       <str name="id">1       </str>       <str name="color">red       </str>       <str name="firstname">tom       </str>     </doc>     <doc>       <str name="id">3       </str>       <str name="color">blue       </str>       <str name="firstname">harry       </str>     </doc>   </result> </response> 

i don't have scala install handy whip example, should going in right direction.

in case haven't seen them, search docs here:
http://docs.basho.com/riak/latest/dev/using/search/


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -