This is about riak search question. How to search utf8 format dat?

郎咸武 langxianzhe at gmail.com
Wed Oct 10 03:28:25 EDT 2012


Anynone may help me? Thanks a lot

2012/10/10 郎咸武 <langxianzhe at gmail.com>

> Hi guys,
> I need your help.
>
> My question is that i can not search utf8 format data using riak search.
>
> *1)The attribute of bucket is in the following*
> (riak at 127.0.0.1)8> C:get_bucket(<<"user1">>).
> [{search,true},
>  {allow_mult,false},
>  {basic_quorum,false},
>  {big_vclock,50},
>  {chash_keyfun,{riak_core_util,chash_std_keyfun}},
>  {dw,quorum},
>  {last_write_wins,false},
>  {linkfun,{modfun,riak_kv_wm_link_walker,mapreduce_linkfun}},
>  {n_val,3},
>  {name,<<"user1">>},
>  {notfound_ok,true},
>  {old_vclock,86400},
>  {postcommit,[]},
>  {pr,0},
>  {precommit,[{struct,[{<<"mod">>,<<"riak_search_kv_hook">>},
>                       {<<"fun">>,<<"precommit">>}]}]},
>  {pw,0},
>  {r,quorum},
>  {rw,quorum},
>  {small_vclock,50},
>  {w,quorum},
>  {young_vclock,20}]
>
> *2)To put a Object to <<"user1">> bucket. The data is utf8 format.*
>
> (trends at jason-lxw)123> f(O), O=riakc_obj:new(<<"user1">>,
> <<"jason5">>,list_to_binary(mochijson:encode({struct, [{name,
> binary_to_list(unicode:characters_to_binary("爱"))},{sex,"male"}]})),
> "application/json").
> {riakc_obj,<<"user1">>,<<"jason5">>,undefined,[],
>            {dict,1,16,16,8,80,48,
>                  {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],...},
>
>  {{[],[],[],[],[],[],[],[],[],[],[[<<...>>|...]],[],[],...}}},
>            <<"{\"name\":\"\\u00e7\\u0088\\u00b1\",\"sex\":\"male\"}">>}
> (((trends at jason-lxw)124> riakc_pb_socket:put(Pid, O).
>
> ok
>
> *3)Using riak search query data*
>
> (ejabberd at meta)120>  riakc_pb_socket:search(Pid, <<"user1">>,
> list_to_binary("sex:mal*")).              There are not any problem.
> {ok,{search_results,[{<<"user1">>,
>                       [{<<"id">>,<<"jason">>},
>                        {<<"name">>,<<"jason">>},
>                        {<<"sex">>,<<"male">>}]},
>                      {<<"user1">>,
>                       [{<<"id">>,<<"jason1">>},
>                        {<<"name">>,<<"jasdfsdf">>},
>                        {<<"sex">>,<<"male">>}]},
>                      {<<"user1">>,
>                       [{<<"id">>,<<"jason2">>},
>                        {<<"name">>,<<195,167,194,142,194,176>>},
>                        {<<"sex">>,<<"male">>}]},
>                      {<<"user1">>,
>                       [{<<"id">>,<<"jason3">>},
>                        {<<"name">>,<<195,167,194,136,194,177>>},
>                        {<<"sex">>,<<"male">>}]},
>                      {<<"user1">>,
>                       [{<<"id">>,<<"jason5">>},
>                        {<<"name">>,<<195,167,194,136,194,177>>},
>                        {<<"sex">>,<<"male">>}]}],
>                     0.0,5}}
> (ejabberd at meta)121>
> (ejabberd at meta)121>  riakc_pb_socket:search(Pid, <<"user1">>,
> list_to_binary("name:jason*")).
> {ok,{search_results,[{<<"user1">>,
>                       [{<<"id">>,<<"jason">>},
>                        {<<"name">>,<<"jason">>},
>                        {<<"sex">>,<<"male">>}]}],
>                     0.0,1}}
> (ejabberd at meta)122>
>
>
> (ejabberd at meta)123> *  But , The result is empty.*
> (ejabberd at meta)123>  riakc_pb_socket:search(Pid, <<"user1">>,
> list_to_binary("name:\"\\u00e7\\u0088\\u00b1\"")).
> {ok,{search_results,[],0.0,0}}
>
> Thanks in advance.
>
> Jason
>
>
> --
> 只为成功找方法,不为失败找理由
>



-- 
只为成功找方法,不为失败找理由
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.basho.com/pipermail/riak-users_lists.basho.com/attachments/20121010/7056af1e/attachment.html>


More information about the riak-users mailing list