Hi, to close this thread, I wrote a very brief blog post documenting basic
usage of secondary indices and get_index using riakc at
http://www.jeremyong.com/blog/2012/07/23/secondary-indices-in-riak-with-erlang/

It's obviously not geared toward expert users (I for one, am not an expert
user) but I'm throwing it out there in case somebody else struggles with
the same issues.

Cheers,
Jeremy

On Sun, Jul 22, 2012 at 2:05 PM, Jeremy Ong <jer...@playmesh.com> wrote:

> Ah perfect that works thanks.
>
> I saw the github issue asking for documentation on this. I feel woefully
> unqualified to write this up, but would be happy to for the benefit of
> other users running into similar issues as I.
>
> Thanks,
> Jeremy
>
>
> On Sun, Jul 22, 2012 at 2:02 PM, Sean Cribbs <s...@basho.com> wrote:
>
>> Jeremy,
>>
>> Your index field must have a "_bin" or "_int" suffix on it to signify
>> whether it is a binary or an integer. Add "_bin" to the field name you have
>> in your example, e.g.
>>
>> MetaData = dict:store(<<"index">>, [{<<"afield_bin">>, <<"avalue">>}],
>> dict:new())
>>
>> On Sun, Jul 22, 2012 at 4:49 PM, Jeremy Ong <jer...@playmesh.com> wrote:
>>
>>> I am trying to store objects with indexed metadata but am running into
>>> various difficulties (commands in bold).
>>>
>>> *Obj = riakc_obj:new(<<"foo">>, <<"bar">>, <<"zing">>).*
>>> {riakc_obj,<<"foo">>,<<"bar">>,undefined,[],undefined,
>>>            <<"zing">>}
>>> *
>>> *
>>> *MetaData = dict:store(<<"index">>, [{"afield", "avalue"}], dict:new()).
>>> *
>>> {dict,1,16,16,8,80,48,
>>>       {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]},
>>>       {{[],[],[],[],[],[],[],[],[],[],[],
>>>         [[<<"index">>,{"afield","avalue"}]],
>>>         [],[],[],[]}}}
>>>
>>> *Obj1 = riakc_obj:update_metadata(Obj, MetaData).*
>>> {riakc_obj,<<"foo">>,<<"bar">>,undefined,[],
>>>            {dict,1,16,16,8,80,48,
>>>                  {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],...},
>>>                  {{[],[],[],[],[],[],[],[],[],[],[],[[...]],[],...}}},
>>>            <<"zing">>}
>>>
>>> *{ok, Pid} = riakc_pb_socket:start_link("127.0.0.1", 8087).*
>>> {ok,<0.103.0>}
>>>
>>> *riakc_pb_socket:put(Pid, Obj1).*
>>> *
>>> *
>>> {error,{0,
>>>         <<"{precommit_fail,[{unknown_field_type,<<\"afield\">>}]}">>}}
>>>
>>>
>>> I get this error when I try other things for the field name too. Any
>>> ideas? I tried to look for documentation but nothing seems to be coming up.
>>>
>>> Thanks,
>>> Jeremy
>>>
>>> _______________________________________________
>>> riak-users mailing list
>>> riak-users@lists.basho.com
>>> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>>>
>>>
>>
>>
>> --
>> Sean Cribbs <s...@basho.com>
>> Software Engineer
>> Basho Technologies, Inc.
>> http://basho.com/
>>
>>
>
_______________________________________________
riak-users mailing list
riak-users@lists.basho.com
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

Reply via email to