0

我有一个测试系统,我已经在librariesbucket 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

相信我设置了桶,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

我错过了什么?我已经多次浏览了搜索方法,但找不到我缺少的东西。请注意,我在激活搜索属性后确实重新启动了。

4

1 回答 1

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
   }
}
于 2015-05-17T23:03:24.313 回答