0

What I am trying to do is access 2i information from another bucket inside a post commit hook written in erlang.

I have been looking around the Riak docs and as many other places that I can think of and I can't seem to find how to query 2i with the Riak internal erlang client.

I can do a query to 2i with the http interface with:

/buckets/TEST/index/pos_int/1/15

and it returns

{"keys":["set2i"]}

I can create an entry with the following code (loaded into riak):

Robj =  riak_object:new(<<"TEST">>, <<"set2i">>, void, "application/json"),
Lst = [{"pos_int", 5}], 
Meta = dict:store(<<"index">>,Lst, dict:new()),
I2obj = riak_object:update_metadata(Robj, Meta)
{ok,C} = riak:local_client().
C:put(I2obj).

This works nicely, but the problem I have is with trying to figure out how to do the same query using the native api for riak. The documentation for anything to do with the riak internal client is effectively non existent.

What all I need:

  • information on how to do a integer range query
  • information on my other 2i query options, in case I need it

Any help is much appreciated.

Luigimax
  • 546
  • 1
  • 5
  • 12

1 Answers1

0

The internals of Riak aren't documented much, but you can try to divine what you are looking for from the source of the Riak client and the 2I module

It would seem that you need to build an index query with riak_index:to_index_query() and then pass the constructed query to the riak_client:get_index() function.

But wouldn't doing a coverage query for every put cause really bad latencies?

Joe
  • 25,000
  • 3
  • 22
  • 44