我是Riak的新手,我试图让Riak搜索正常运行,但到目前为止我还是失败了。我已经列出了我在下面尝试的步骤,请告知我错过了什么。
1)创建索引:
curl -X PUT http://192.168.189.153:10018/search/index/ix1 \
-H 'Content-Type: application/json' \
-d '{"schema":"_yz_default"}'
2)创建并激活索引
riak-admin bucket-type create citytype '{"props":{"search_index":"ix1"}}'
riak-admin bucket-type activate citytype
4)使用Ruby
创建require 'riak'
client = Riak::Client.new(:nodes => [
{:host => "192.168.189.153", :pb_port => 10017},
{:host => "192.168.189.153", :pb_port => 10027},
{:host => "192.168.189.153", :pb_port => 10037}
])
city = {
:name => 'Roskilde',
:countrycode => 'DK',
:location => '1.2',
:population => 80000
}
city_bucket = client.bucket_type('citytype').bucket('byer')
new_city = city_bucket.get_or_new(city[:name])
new_city.data = city
new_city.store(w: 3, dw: 2)
5)使用Ruby检索
require 'riak'
client = Riak::Client.new(:nodes => [
{:host => "192.168.189.153", :pb_port => 10017}
])
city_bucket = client.bucket_type('citytype').bucket('byer')
fetched = city_bucket.get('Roskilde')
p fetched
results = client.search("ix1", "name:Roskilde")
p results
p results['docs']
6)输出
ruby search1.rb
#<Riak::RObject {byer,Roskilde} [#<Riak::RContent [application/json]:{"name"=>"Roskilde", "countrycode"=>"DK", "location"=>"1.2", "population"=>80000}>]>
{"max_score"=>0.0, "num_found"=>0, "docs"=>[]}
[]
7)通过HTTP
http://192.168.189.153:10018/types/citytype/buckets/byer/keys/Roskilde
{"name":"Roskilde","countrycode":"DK","location":"1.2","population":80000}
http://192.168.189.153:10018/search/query/ix1?wt=json&q=name:Roskilde
{"responseHeader":{"status":0,"QTime":10,"params":{"192.168.189.153:10034":"_yz_pn:51 OR _yz_pn:39 OR _yz_pn:36 OR _yz_pn:27 OR _yz_pn:24 OR _yz_pn:12","shards":"192.168.189.153:10014/internal_solr/ix1,192.168.189.153:10024/internal_solr/ix1,192.168.189.153:10034/internal_solr/ix1","q":"name:Roskilde","wt":"json","192.168.189.153:10014":"_yz_pn:64 OR (_yz_pn:61 AND (_yz_fpn:61)) OR _yz_pn:60 OR _yz_pn:57 OR _yz_pn:48 OR _yz_pn:45 OR _yz_pn:33 OR _yz_pn:21 OR _yz_pn:9","192.168.189.153:10024":"_yz_pn:54 OR _yz_pn:42 OR _yz_pn:30 OR _yz_pn:18 OR _yz_pn:15 OR _yz_pn:6 OR _yz_pn:3"}},"response":{"numFound":0,"start":0,"maxScore":0.0,"docs":[]}}
8)错误日志
solr.log
文件只有可解释的错误(出于绝望的情况我做了一些奇怪的通配符搜索)
error.log
文件显示了许多这样的错误,但是最近的一些新测试都没有:
23:15:41.308 [error] Error in process <0.4385.0> on node 'dev1@192.168.189.153' with exit value: {{badmatch,['dev3@192.168.189.153']},[{yz_index,wait_for_index,3,[{file,"src/yz_index.erl"},{line,415}]}]}
9)版本
karsten@ubuntu:~/riak$ dev/dev1/bin/riak-admin status | grep riak_kv_version
riak_kv_version : <<"2.0.2-99-g404619c">>
karsten@ubuntu:~/riak$
karsten@ubuntu:~/riak$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.3 LTS
Release: 14.04
Codename: trusty
karsten@ubuntu:~/riak$
答案 0 :(得分:0)
默认架构[0]希望您将每个字段的数据类型附加到其名称,例如name_s
表示字符串,或population_i
表示整数。否则,该字段匹配默认值,该默认值明确跳过索引:
<dynamicField name="*" type="ignored" />
[0] https://raw.githubusercontent.com/basho/yokozuna/develop/priv/default_schema.xml