I am using riak2.2.3, and trying to search in a map bucket type, but nothing is ever returned.
I've configured a bucket type "dist_cache" on the memory backend:
# 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
I've then enable search in /etc/riak/:
search = on
Then I have configured an index, with the default schema and associated it with the bucket type (see above).
I can successfully store and retrieve values, using keys, in that bucket. I have stored 3 values in registers: binary data, integer (timestamp) and a string:
[
{{"attrs", :register}, <<131, 97, 111>>},
{{"iat_i", :register}, "1540923453"},
{{"test_s", :register}, "paul"}
]
(displayed after formatting from Elixir shell, using Elixir's Riak library.)
However, nothing is found when I try searching these values:
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}}
In addition, /var/log/riak/solr.log doesn't show any error message for these requests.
Am I missing something? I needed to remove a few options from the java startup options, but now it seems java is up and running, and solr.log does show error message when trying malformed request.
EDIT:
After trying @vempo's solutions:
I have suffixed the field with _register, however it still does not work. Here is how the field is:
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"}
]
but the search request still returns no result:
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:*")
Still know output in /var/log/riak/solr.log, and index seems correctly setup:
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]
]}
For searching within maps the rules are different. According to Searching with Data Types, there are four schemas for maps, one for each embedded type:
So that in your case you should be searching attrs_register
, iat_i_register
, and test_s_register
.
As a side note, the suffixes _s
and _i
are probably redundant. They are used by the default schema to decide the type of a regular field, but are useless with embedded datatypes).
UPDATE
And to sum up the rules:
test
will be indexed as test_flag
(query test_flag:*
)test
will be indexed as test_register
(query test_register:*
)test
will be indexed as test_counter
(query test_counter:*
)test
will be indexed as test_set
(query test_set:*
)This is nicely shown in the table in Searching with Data Types: Embedded Schemas.
See also the definition of dynamic fields for embedded datatypes in the default schema, section <!-- Riak datatypes embedded fields -->
.