我正在使用riak2.2.3,并试图在映射桶类型中搜索,但是没有返回任何内容。
我在内存后端配置了一个桶类型"dist_cache“:
# riak-admin bucket-type status dist_cache
dist_cache is active
active: true
allow_mult: true
backend: <<"memory_mult">>
basic_quorum: false
big_vclock: 50
chash_keyfun: {riak_core_util,chash_std_keyfun}
claimant: 'riak@127.0.0.1'
datatype: map
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: <<"expirable_token">>
small_vclock: 50
w: quorum
young_vclock: 20然后在/etc/riak/中启用搜索:
search = on然后,我用默认模式配置了一个索引,并将其与桶类型相关联(参见上文)。
我可以使用键成功地在那个桶中存储和检索值。我在寄存器中存储了3个值:二进制数据、整数(时间戳)和一个字符串:
[
{{"attrs", :register}, <<131, 97, 111>>},
{{"iat_i", :register}, "1540923453"},
{{"test_s", :register}, "paul"}
](使用Elixir的Riak库,在从Elixir格式化后显示。)
但是,当我尝试搜索这些值时,什么都找不到:
iex(74)> :riakc_pb_socket.search(pid, "expirable_token", "iat_i:[0 TO *]")
{:ok, {:search_results, [], 0.0, 0}}
iex(75)> :riakc_pb_socket.search(pid, "expirable_token", "iat_i:1540923453")
{:ok, {:search_results, [], 0.0, 0}}
iex(76)> :riakc_pb_socket.search(pid, "expirable_token", "test_s:paul")
{:ok, {:search_results, [], 0.0, 0}}
iex(77)> :riakc_pb_socket.search(pid, "expirable_token", "test_s:*")
{:ok, {:search_results, [], 0.0, 0}}此外,/var/log/riak/solr.log不显示这些请求的任何错误消息。
我是不是遗漏了什么?我需要从java启动选项中删除几个选项,但现在看来java已经启动并运行,solr.log在尝试格式错误的请求时确实显示了错误消息。
编辑:
在尝试@vempo的解决方案之后:
我已经用_register作为字段的后缀,但是它仍然不能工作。以下是该领域的情况:
iex(12)> APISexAuthBearerCacheRiak.get("ddd", opts)
[
{{"attrs", :register}, <<131, 98, 0, 0, 1, 188>>},
{{"iat_i", :register}, "1542217847"},
{{"test_flag", :flag}, true},
{{"test_register", :register}, "pierre"}
]但是搜索请求仍然没有返回结果:
iex(15)> :riakc_pb_socket.search(pid, "expirable_token", "test_register:*")
{:ok, {:search_results, [], 0.0, 0}}
iex(16)> :riakc_pb_socket.search(pid, "expirable_token", "test_register:pierre")
{:ok, {:search_results, [], 0.0, 0}}
iex(17)> :riakc_pb_socket.search(pid, "expirable_token", "test_register:*")
{:ok, {:search_results, [], 0.0, 0}}
iex(18)> :riakc_pb_socket.search(pid, "expirable_token", "test_flag:true")
{:ok, {:search_results, [], 0.0, 0}}
iex(19)> :riakc_pb_socket.search(pid, "expirable_token", "test_flag:*") 仍然知道/var/log/riak/solr.log中的输出,索引似乎正确设置:
iex(14)> :riakc_pb_socket.list_search_indexes(pid)
{:ok,
[
[index: "expirable_token", schema: "_yz_default", n_val: 3],
[index: "famous", schema: "_yz_default", n_val: 3]
]}发布于 2018-11-12 06:57:16
对于在地图中搜索,规则是不同的。根据使用数据类型进行搜索,映射有四种模式,每种嵌入类型都有一个:
因此,在您的示例中,您应该搜索attrs_register、iat_i_register和test_s_register。
顺便提一句,后缀_s和_i可能是多余的。它们被默认模式用来决定常规字段的类型,但是对于嵌入式数据类型来说是无用的)。
更新
总结一下这些规则:
test的标志字段将被索引为test_flag (查询test_flag:*)。test的寄存器字段将被索引为test_register (查询test_register:*)。test的计数器字段将被索引为test_counter (查询test_counter:*)。test的集合字段将被索引为test_set (查询test_set:*)使用数据类型进行搜索:嵌入式模式中的表很好地显示了这一点。
还请参阅默认模式节<!-- Riak datatypes embedded fields -->中嵌入式数据类型的动态字段的定义。
https://stackoverflow.com/questions/53071329
复制相似问题