0

I have a test system and I've created and activated libraries as a search property on the bucket type clients.

➜  riak-2.1.0  curl http://localhost:8098/buckets/coding-with-riak/props
{"props":{"allow_mult":false,"basic_quorum":false,"big_vclock":50,"chash_keyfun":{"mod":"riak_core_util","fun":"chash_std_keyfun"},"dvv_enabled":false,"dw":"quorum","last_write_wins":false,"linkfun":{"mod":"riak_kv_wm_link_walker","fun":"mapreduce_linkfun"},"n_val":3,"name":"coding-with-riak","notfound_ok":true,"old_vclock":86400,"postcommit":[],"pr":0,"precommit":[],"pw":0,"r":"quorum","rw":"quorum","search_index":"libraries","small_vclock":50,"w":"quorum","write_once":false,"young_vclock":20}}%
➜  riak-2.1.0  bin/riak-admin bucket-type status clients
clients is active

active: true
allow_mult: true
basic_quorum: false
big_vclock: 50
chash_keyfun: {riak_core_util,chash_std_keyfun}
claimant: 'riak@127.0.0.1'
dvv_enabled: true
dw: quorum
last_write_wins: false
linkfun: {modfun,riak_kv_wm_link_walker,mapreduce_linkfun}
n_val: 3
notfound_ok: true
old_vclock: 86400
postcommit: []
pr: 0
precommit: []
pw: 0
r: quorum
rw: quorum
search_index: <<"libraries">>
small_vclock: 50
w: quorum
young_vclock: 20

I believe I set the bucket, coding-with-riak, in a way that makes it ready for search:

➜  ~  curl http://localhost:8098/buckets/coding-with-riak/props
{"props":{"allow_mult":false,"basic_quorum":false,"big_vclock":50,"chash_keyfun":{"mod":"riak_core_util","fun":"chash_std_keyfun"},"dvv_enabled":false,"dw":"quorum","last_write_wins":false,"linkfun":{"mod":"riak_kv_wm_link_walker","fun":"mapreduce_linkfun"},"n_val":3,"name":"coding-with-riak","notfound_ok":true,"old_vclock":86400,"postcommit":[],"pr":0,"precommit":[],"pw":0,"r":"quorum","rw":"quorum","search_index":"libraries","small_vclock":50,"w":"quorum","write_once":false,"young_vclock":20}}%

But when I try to search, through the Ruby client or through cURL, it errors:

>> coding.keys
Riak::Bucket#keys is an expensive operation that should not be used in production.
=> ["ruby", "python", "go"]
>> results = client.search("coding-with-riak", "maintainer_s:*")
Riak::ProtobuffsErrorResponse: Expected success from Riak but received 0. No index <<"coding-with-riak">> found.

cURL has similar results:

➜ curl "http://localhost:8098/search/query/libraries?wt=json&q=popular_b:true"
(23) Failed writing body

What did I miss? I've walked through the search how-to more than a few times and can't find what I'm missing. Note that I did reboot after activating the search properties.

mbb
  • 3,052
  • 1
  • 27
  • 28

1 Answers1

1

The kind folks on #riak IRC corrected both problems, which are different.

On the ruby side, I need to supply the search index, not the bucket:

>> results = client.search("libraries", "maintainer_s:basho")
=> {"max_score"=>1.8109302520751953, "num_found"=>1, "docs"=>[{"score"=>"1.81093030000000010382e+00", "_yz_rb"=>"coding-with-riak", "_yz_rt"=>"default", "_yz_rk"=>"ruby", "_yz_id"=>"1*default*coding-with-riak*ruby*56", "name_s"=>"Ruby Client", "maintainer_s"=>"basho", "popular_b"=>"true"}]}

And for cURL queries, I was having an encoding issue due to my host file mapping of localhost as used above. Using 127.0.0.1 worked:

➜  ~  curl "http://127.0.0.1:8098/search/query/libraries?wt=json&q=popular_b:true" | json_pp
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   866  100   866    0     0  81169      0 --:--:-- --:--:-- --:--:-- 86600
{
   "responseHeader" : {
      "QTime" : 9,
      "params" : {
         "shards" : "127.0.0.1:8093/internal_solr/libraries",
         "wt" : "json",
         "127.0.0.1:8093" : "_yz_pn:63 OR (_yz_pn:60 AND (_yz_fpn:60)) OR _yz_pn:59 OR _yz_pn:56 OR _yz_pn:53 OR _yz_pn:50 OR _yz_pn:47 OR _yz_pn:44 OR _yz_pn:41 OR _yz_pn:38 OR _yz_pn:35 OR _yz_pn:32 OR _yz_pn:29 OR _yz_pn:26 OR _yz_pn:23 OR _yz_pn:20 OR _yz_pn:17 OR _yz_pn:14 OR _yz_pn:11 OR _yz_pn:8 OR _yz_pn:5 OR _yz_pn:2",
         "q" : "popular_b:true"
      },
      "status" : 0
   },
   "response" : {
      "maxScore" : 1.2513144,
      "docs" : [
         {
            "_yz_id" : "1*default*coding-with-riak*go*50",
            "_yz_rt" : "default",
            "popular_b" : true,
            "name_s" : "Go Client",
            "_yz_rb" : "coding-with-riak",
            "_yz_rk" : "go",
            "maintainer_s" : "community"
         },
         {
            "_yz_id" : "1*default*coding-with-riak*ruby*56",
            "_yz_rt" : "default",
            "popular_b" : true,
            "name_s" : "Ruby Client",
            "_yz_rb" : "coding-with-riak",
            "maintainer_s" : "basho",
            "_yz_rk" : "ruby"
         }
      ],
      "start" : 0,
      "numFound" : 2
   }
}
mbb
  • 3,052
  • 1
  • 27
  • 28