Hi Joey, When using secondary indexes the index names must end in either `_int` for integer indexes or `_bin` for binary indexes in order for them to be recognised by the system [1]. All indexes must be set when you write the objects.
You must also ensure that the bucket you are writing the objects to are using either the memory or leveldb backends as bitcask does not support secondary indexes. Can you verify that this is the case? Are there any error messages in the logs? Which exact client version are you using? [1] http://docs.basho.com/riak/latest/cookbooks/Secondary-Indexes---Configuration/ Best regards, Christian On 19 Jul 2013, at 07:09, Joey Yandle <dra...@dancingdragon.be> wrote: > Hi everbody, > > I'm using riak to store large numbers of FX rates, to allow for deep > backtests of trading strategies. My code seems to be working, except > that I don't get any keys back from 2i range requests. > > Here's the code which puts the rate into riak (the rate is itself a > protocol buffers object): > > std::string s = p->rate().time(); > std::string rate; > p->rate().SerializeToString(&rate); > > mrx::riak::RpbPutReqPtr req(new mrx::riak::RpbPutReq()); > > req->set_bucket(symbol); > req->set_key(s); > > mrx::riak::RpbContent* content = req->mutable_content(); > > content->set_value(rate); > > mrx::riak::RpbPair* index = content->add_indexes(); > > index->set_key(vm["riak.index"].as<std::string>()); > index->set_value(s); > > Here's the code which does the index search: > > mrx::riak::RpbIndexReqPtr req(new mrx::riak::RpbIndexReq()); > > req->set_bucket(symbol); > req->set_index(vm["riak.index"].as<std::string>()); > req->set_qtype(mrx::riak::RpbIndexReq::range); > > req->set_range_min(vm["rates.start"].as<std::string>()); > req->set_range_max(vm["rates.end"].as<std::string>()); > > I originally used the string "time" as the index key, and there was no > error when doing the put command. However, when trying to search with > this index, I got the following error: > > [{unknown_field_type,<<"time">>}] > > This error went away when I used "time_bin" as the index. However, > regardless of what I use as the index key when doing the put, I never > get any keys returned during the search. > > Can someone point me to a working example of using protocol buffers to > do a put and subsequent index search? The examples online only show the > latter. > > thanks, > > Joey > > _______________________________________________ > riak-users mailing list > riak-users@lists.basho.com > http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
_______________________________________________ riak-users mailing list riak-users@lists.basho.com http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com