I have some clue how to add secondary index but data types are confusing
for me:
> ObjNew = riakc_obj:new(<<"test_users">>, <<"adm">>, <<"My value">>).
> Index = [ <<"field1_bin">>, <<"my_index">>].
> Meta = dict:store(<<"index">>, Index, dict:new()).
> ObjNewMeta = riakc_obj:update_metadata(ObjNew, Meta).
> riakc_pb_socket:put(Pid, ObjNewMeta).
** exception exit: {noproc,
{gen_server,call,
[<0.124.0>,
{req,
{rpbputreq,<<"test_users">>,<<"adm">>,undefined,
{rpbcontent,<<"My
value">>,undefined,undefined,
undefined,undefined,undefined,undefined,undefined,undefined,
[{rpbpair,<<"field"...>>,[...]}]},
undefined,undefined,undefined,undefined,undefined,undefined,
undefined},
60000},
infinity]}}
in function gen_server:call/3 (gen_server.erl, line 188)
So, I don't know what the problem is. I can only guess that index data type
may not be correct, but it's just guess.
Any ideas?
-- Buriwoy
On Sun, Mar 11, 2012 at 1:05 PM, Buri Arslon <[email protected]> wrote:
> Thanks for your reply Jeremiah!
>
> I guess I am "greener" than you :)
>
> Before posting to the list, I looked through riak documentation, the list.
> I did find some postings on the subject but almost all of'em were questions
> than answers. The answers I could find were so ambiguous that I wasn't able
> to use them.
>
> I've tried riakc_obj:update_metadata but got this error:
> http://dpaste.com/715011/
>
> So, I hoped to find a working example. I'm too new to Erlang to read the
> source and solve my problems.
>
> Thanks again,
> -- Buriwoy
>
>
> On Sun, Mar 11, 2012 at 12:46 PM, Jeremiah Peschka <
> [email protected]> wrote:
>
>> Howdy Buri,
>>
>> I'm not an Erlang expert, or even something remotely resembling competent
>> with Erlang, however, I believe I have tracked down what you're looking for.
>>
>> You can use one of the riakc_pb_socket:get_index functions to pull back
>> data from an index. If you look at the source on the methods, you'll see
>> that they're just wrappers around a MapReduce call. As far as setting the
>> values... I think you'll have to make a call to riakc_obj:update_metadata
>> and add the index metadata in by hand, but I could be wrong on that one.
>>
>> If I'm wrong, hopefully someone on the list will correct my Erlang-y
>> ignorance.
>>
>> get_index/4 [1]
>> get_index/5 [3]
>> get_index/6 [2]
>> get_index/7 [4]
>>
>>
>>
>> [1]:
>> https://github.com/basho/riak-erlang-client/blob/master/src/riakc_pb_socket.erl#L677
>> [2]:
>> https://github.com/basho/riak-erlang-client/blob/master/src/riakc_pb_socket.erl#L695
>> [3]:
>> https://github.com/basho/riak-erlang-client/blob/master/src/riakc_pb_socket.erl#L714
>> [4]:
>> https://github.com/basho/riak-erlang-client/blob/master/src/riakc_pb_socket.erl#L732
>> ---
>> Jeremiah Peschka - Managing Director, Brent Ozar PLF, LLC
>> Microsoft SQL Server MVP
>>
>> On Mar 11, 2012, at 11:06 AM, Buri Arslon wrote:
>>
>> > Hi everybody,
>> >
>> > I can't find any tutorial or docs on secondary indexes. Here (
>> http://lists.basho.com/pipermail/riak-users_lists.basho.com/2011-October/005952.html)
>> it was stated that the docs would be updated but I can't find it.
>> >
>> > I just wanted a doc which explains how to use secondary indexes with
>> native erlang client. Riak docs have examples for http api but not for
>> erlang client.
>> >
>> > Can anyone refer me to appropriate docs/tutorials?
>> >
>> > Thanks,
>> > -- Buriwoy
>> > _______________________________________________
>> > riak-users mailing list
>> > [email protected]
>> > http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>>
>>
>
_______________________________________________
riak-users mailing list
[email protected]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com