basho / riak-erlang-client

The Riak client for Erlang.
Apache License 2.0
311 stars 188 forks source link

MapReduce on secondary indexes (2i) [JIRA: CLIENTS-1027] #330

Closed mikrofusion closed 7 years ago

mikrofusion commented 7 years ago

The examples show how to do link walks to fetch the object pointed to by the link. Is there something similar that can be done for secondary indexes?

For example, I can call riakc_pb_socket:get_index_eq to get a list of keys that match the secondary index, but then have to make another trip from the server to Riak to get the actual objects that have those secondary indexes. Would be preferred to be able to do a map_reduce similar to how the examples show a link walk so that the full result (and not just the key) is returned.

Thanks in advance for any help.

lukebakken commented 7 years ago

Hi Mike -

Using MR this way is not recommended. Map/Reduce is intended for batch processing during "off peak hours" as it places quite a bit of load on your cluster.

When inserting data into a secondary index, you can return the indexed data using return_terms. That could be an option depending on what data you need from the objects.

Otherwise, it would be faster to retrieve individual objects in parallel once you have their keys.

Basho-JIRA commented 7 years ago

Fixed, or closed via GitHub issues.

[posted via JIRA by Alexander Moore]