Riak搜索返回“无索引”和“(23)失败的写作身体”

时间:2015-05-17 22:21:50

标签: ruby bash riak riak-search

我有一个测试系统,我已经创建并激活libraries作为存储桶类型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

相信我设置了一个桶coding-with-riak,以便为搜索做好准备:

➜  ~  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}}%

但是当我尝试通过Ruby客户端或通过cURL进行搜索时,它会出错:

>> 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也有类似的结果:

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

我错过了什么?我已经走了search how-to多次,找不到我所缺少的东西。请注意,我在激活搜索属性后重新启动。

1 个答案:

答案 0 :(得分:1)

#riak IRC上那些善意的人纠正了两个不同的问题。

在ruby方面,我需要提供搜索索引,而不是存储桶:

>> 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"}]}

对于cURL查询,由于上面使用的localhost主机文件映射,我遇到了编码问题。使用127.0.0.1工作:

➜  ~  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
   }
}