Creating object like this:
 f(O),O=riakc_obj:new(<<"user">>, <<"jason">>,
list_to_binary("[{\"name\":\"jason\"},{\"sex\":\"male\"}]"),
"application/json").


72> riakc_pb_socket:search(Pid, <<"user2">>,
list_to_binary("\"sex\":\"male\"")).
{ok,{search_results,[{<<"user2">>,
                      [{<<"id">>,<<"jason">>},
                       {<<"name">>,<<"jason">>},
                       {<<"sex">>,<<"male">>}]}],
                    0.35355299711227417,1}}
73> riakc_pb_socket:search(Pid, <<"user2">>,
list_to_binary("\"sex\":\"mal*\"")). *%% But this is empty. Why?*
{ok,{search_results,[],0.0,0}}
74> riakc_pb_socket:search(Pid, <<"user2">>,
list_to_binary("\"sex\":\"male\"")).
{ok,{search_results,[{<<"user2">>,
                      [{<<"id">>,<<"jason">>},
                       {<<"name">>,<<"jason">>},
                       {<<"sex">>,<<"male">>}]}],
                    0.35355299711227417,1}}


2012/8/31 郎咸武 <langxian...@gmail.com>

> anyone may reply me,thanks a lot.
>
> 在 2012年8月30日星期四,郎咸武 写道:
>
>> who can give me some idea
>>
>> 在 2012年8月30日星期四,郎咸武 写道:
>>
>> Hi guys,
>>        I need your help.
>>
>> Version:
>> 1)riak-erlang-client-1.3
>> 2)riak-1.2
>> 3)Erlang R14B04 (erts-5.8.5) [source] [64-bit]
>>
>> This is my bucket attributs in the following
>>
>> (riak@127.0.0.1)52> {ok,C} = riak:local_client().
>>
>> {ok,{riak_client,'riak@127.0.0.1',undefined}}
>> (riak@127.0.0.1)53> C:set_bucket(<<"user">>,[{precommit,
>> [{struct,[{<<"mod">>,<<"riak_search_kv_hook">>},{<<"fun">>,<<"precommit">>}]}]}]).
>> ok
>> (riak@127.0.0.1)54> C:get_bucket(<<"user">>).
>>
>> [{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,<<"user">>},
>>  {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}]
>>
>> *------------------*
>> *In the client*
>> *To new a object  and search it*
>> 147> f(O),O=riakc_obj:new(<<"user">>, <<"jason">>, <<"jasonlang">>)
>> 147> .
>> {riakc_obj,<<"user">>,<<"jason">>,undefined,[],undefined,
>>            <<"jasonlang">>}
>>
>> 150> riakc_pb_socket:put(Pid,O).
>> ok
>> 151> riakc_pb_socket:search(Pid, <<"user">>, "jason*")
>> 151> .
>> {ok,{search_results,[{<<"user">>,
>>
>> [{<<"id">>,<<"jason">>},{<<"value">>,<<"jasonlang">>}]}],
>>                     0.0,1}}
>> 152>
>>
>> *This search operator  is ok*
>>
>> *TO new another object and search it*
>>
>> 152> f(O),O=riakc_obj:new(<<"user">>, <<"lang">>, <<"langzhe">>)
>> 152> .
>> {riakc_obj,<<"user">>,<<"lang">>,undefined,[],undefined,
>>            <<"langzhe">>}
>> 153> riakc_pb_socket:put(Pid,O).
>> ok
>> 154> riakc_pb_socket:search(Pid, <<"user">>, "langzh*")
>> 154> .
>> {ok,{search_results,[{<<"user">>,
>>
>> [{<<"id">>,<<"lang">>},{<<"value">>,<<"langzhe">>}]}],
>>                     0.0,1}}
>> *This is ok too*
>> *
>> *
>> *Search the objects:*
>> 157> riakc_pb_socket:search(Pid, <<"user">>, "langzh*\"\"jason*")
>> 157> .
>> {ok,{search_results,[{<<"user">>,
>>
>> [{<<"id">>,<<"jason">>},{<<"value">>,<<"jasonlang">>}]},
>>                      {<<"user">>,
>>
>> [{<<"id">>,<<"lang">>},{<<"value">>,<<"langzhe">>}]}],
>>                     0.0,2}}
>> 158>
>> This is ok too.
>> -------------------------------------------------------------------
>> *In the above is ok.*
>>
>> --
>> 只为成功找方法,不为失败找理由
>>
>
>
> --
> 只为成功找方法,不为失败找理由
>



-- 
只为成功找方法,不为失败找理由
_______________________________________________
riak-users mailing list
riak-users@lists.basho.com
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

Reply via email to