Pavel S.
Pavel S.

Reputation: 12352

Riak 2i - list index values

Is it possible to list all secondary index values previously saved in Riak bucket (leveldb, 2i enabled)? Having the following data in Riak:

curl -XPOST localhost:8098/types/indexes/buckets/users/keys/x -H 'x-riak-my_bin: a'
curl -XPOST localhost:8098/types/indexes/buckets/users/keys/y -H 'x-riak-my_bin: b'

I'd like to be able to send a query which would return me {a, b} as a result (or possibly a stream handle to the same result, if it's too big). Something like:

curl -XGET localhost:8098/types/indexes/buckets/users/index/my_bin/_

Is is possible get such information from Riak?

Note: I am NOT interested in getting the actual object keys - {x, y} in our case.

Upvotes: 0

Views: 391

Answers (1)

Joe
Joe

Reputation: 28366

I don't believe that functionality is a provided. It seems that Riak stores the 2i values in a form like {i,Bucket,Index,Value,Key}. An ranged index request then does a fold starting from {i,Bucket,Index,FirstValue,_} and returns what it finds. The default is to return the keys found, and you can request the values as well, but not the value without the keys. So you would have to use either map-reduce or some client-side code to remove the bucket/key and deduplicate the value list.

Upvotes: 1

Related Questions