basho/riak-python-client — pull request #252 by seancribbs (2013-07-03 21:23:06+00:00)
Title: Riak 1.4 Feature: Secondary Index Enhancements

Riak 1.4 introduces several new features to secondary indexes,
including pagination (limiting result sets and providing a
continuation "cursor"), streaming (not buffering the entire result
set on the server-side), and returning the value of the index entry
as well as the key.

- [x] Support streaming results (stream = true)
- [x] Support max_results (pagination)
- [x] Support continuation (next page in pagination)
- [x] Support return_terms (get index value)

```python
# These are some suggestions for how the API might look. Note that
# pagination, streaming, and return_terms can all be combined into
# the same request.

# Streaming
for keys in bucket.stream_index("foo_int", 2, 10):
# `keys` is a list() of str()
print keys

# Pagination
page = bucket.get_index("foo_int", 2, 10, max_results=1000)
for key in page: # paginated results should be iterable
print key
page.continuation # Returns the opaque continuation
more = page.next_page() # Automatically fetches the next set of results
# This should take the same options as get_index()

# Return terms
pairs = bucket.get_index("foo_int", 2, 10, return_terms=True)
pairs[0] # Is a tuple of (index_value, key)
# Since this is an integer index, the index_value
# should be coerced to an int()
```