basho/riak-php-client — pull request #19 by MightyE (2011-12-13 15:59:39+00:00)
Title: This pull request adds secondary indexes to Map/Reduce operations

This pull request adds secondary indexes to Map/Reduce operations, where previously they were only available on a bucket level.

Also I'm curious if the behavior where a single document with multiple values for a index returns multiple times for an index range search. For bucket-level operations I provided a de-dupe option, but for Map/Reduce, this may cause unexpected results when tabulating data (such documents could be counted multiple times). I wrote a unit test that assumes this behavior is intentional.

## Secondary Indexes in Map/Reduce ##
The same search format used for RiakBucket::indexSearch() may be used during Map/Reduce operations during the input phase. This is only valid for bucket-level operations, and cannot be combined with other filtration methods such as key filters.

# Use secondary indexes to speed up our Map/Reduce operation
$result = $client
->add("bucket_name") // Begin Map/Reduce
->indexSearch("index_name", "int", 1)
->map("function (v) { return [v.key]; }")
->reduce("Riak.reduceSort")
->run();