Retrieve all keys of an index?

Russell Brown russell.brown at mac.com
Wed Apr 10 04:34:28 EDT 2013


Hi Jeff,

On 10 Apr 2013, at 02:54, Jeff Peck <jeffp at tnrglobal.com> wrote:

> Hello,
> 
> In Riak, is it possible to retrieve all of the keys of an index? I do not want the object keys in this case, but rather the actual index keys.

I think this is covered by a feature I'm adding, if I understand what you're asking for. Does this example give you the values you want?

Say in current riak the query you might do would be

curl localhost:8098/buckets/your_bucket/index/catalog_bin/1000/2000

would get you a list of keys. In 1.4 there'll be the option to get the index values as well, so the results would be an array of pairs like {results: ["1001" : "primary_key"]} where the first element is the value of catalog_bin index and the second the primary key of the object.

Is that what you're asking for?

Cheers

Russell

> 
> I am not sure that I am using the correct terminology, but to illustrate, consider a Riak bucket with the following objects, where "catalog" is indexed to "catalog_bin":
> 
> {'url':'http://www.google.com', 'catalog':'1001'}
> {'url':'http://www.yahoo.com', 'catalog':'1001'}
> {'url':'http://www.blah.com', 'catalog': 1002'}
> {'url':'http://www.test123.com', 'catalog': 1002'}
> {'url':'http://www.test12345.com', 'catalog': 1003'}
> 
> I would like to retrieve all of the keys for the index catalog_bin. From the above example, that would be:
> 1001
> 1002
> 1003
> 
> To illustrate further, it would be the equivalent of the following in MySQL, if the above data were to be in a table called "urls":
> 
> 	SELECT catalog FROM urls GROUP BY catalog;
> 
> I would appreciate any advice as to how to query for this in Riak, or if this not feasible, then perhaps a suggestion for the best way to organize the data.
> 
> Thank you,
> Jeff
> _______________________________________________
> riak-users mailing list
> riak-users at lists.basho.com
> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com





More information about the riak-users mailing list