several 2i in the query

Ryan Zezeski rzezeski at
Thu Aug 2 10:12:43 EDT 2012

Hi Boris,

My comments are inline.

On Wed, Aug 1, 2012 at 9:01 AM, Ilyushonak Barys <barys_ilyushonak at
> wrote:

> Hi, riak users
> I have object with two different secondary indexes - status and type. For
> example, I would like to query all keys with status=new AND type=gloves.
> As wiki says "In version 1.0 of Riak, index queries are only supported on
> one index field at a time." (
> I would like to know: if anything changed in this field since 1.0?

Nothing has changed in regards to querying multiple indexes.  I.e. only one
index can be queried.


> I have found the following solutions for this task:
> 1. Create separate index value for specified pair status and type, for
> example {<<"index">>, [{<<"status_and_type_bin ">>, term_to_binary({new,
> gloves})}]}

Do you really want to use term_to_binary here?  Perhaps you could get away
with a binary with a known separator like <<"new_gloves">> or
<<"new|gloves">> etc.  It should save a few bytes per object over external
term format.

2. Use the query result by only one index as map-reduce input pipe and
> filter values in MR.

If you go this route make sure to query on the more limiting index so MR
can process the least amount of objects.  Each object needed by MR is
random access.

> 3. Maybe I think too relational and should use other object structure?

Perhaps, that all depends on your problem.  The data model, how often data
is updated, the types of queries you need to perform, how much data you
have, what kind of latency requirements you have, etc.  Feel free to
elaborate more.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the riak-users mailing list