Retrieve all keys of an index?

Jeff Peck jeffp at tnrglobal.com
Wed Apr 10 14:43:18 EDT 2013


Russell,

Yes, that is what I am asking for. In the range query example that you provided, that would produce a set of object keys. It would be excellent if I could also get the keys themselves.

Still, I think the best example that describes what I am looking for is in the MySQL query that I showed:

	SELECT catalog FROM urls GROUP BY catalog;

After writing the original email, I managed to do exactly that with a map-reduce function. However, since then my index has grown to about 900,000 documents and the map-reduce query now times out (although I have yet to delve into the configuration try to adjust so that it will not time out).

Still, tt seems reasonable that if the index exists, then I should be able quickly access a list of all index keys without having to examine all of the data. Your solution appears that it would alleviate the situation, despite not being exactly what I'm looking for.

I look forward to the next release and appreciate the work done on Riak and fast responses on this list.

In the meantime, I will see if I can configure riak so my map-reduce query does not time out.

(If anybody on this list would like to see the map-reduce query that I am using for their own reference, please message me. It's actually quite basic, but if you are getting started like I am, it sometimes helps to see an example. I'm not going to clutter the email with it unless somebody would like to see it.)

- Jeff

On Apr 10, 2013, at 4:34 AM, Russell Brown <russell.brown at mac.com> wrote:

> 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