If you look at the riak-erlang-client here 
https://github.com/basho/riak-erlang-client/blob/develop/src/riakc_pb_socket.erl#L1129
 there is a client API call that was implemented for CS (riak s2, or whatever 
it is called, the large object store thingy that basho had) that will use the 
$keys index, but in the back end calls fold_objects rather than fold_keys on 
eleveldb, and so returns the whole object. NOTE: this is equivalent to r=1, you 
don’t get a quorum read here, but a single vnode per-value only. I don’t know 
if other clients added this API, but it would not be hard to add to any client 
that supports 2i. Like I say, originally it was for riakCS, but it’s open 
source and part of the release for 4 years now, so hardly a secret.

Cheers

Russell

On 13 Feb 2017, at 06:18, Alex Feng <[email protected]> wrote:

> Hi Russell,
> 
> In your reply, you mentioned this,
> 
> >> There is also the feature that can return the actual riak objects for a 
> >> $keys index search,
> >>You can pack the index terms with data and return the terms in a query so 
> >>that you don’t need a further object fetch (see >>return_terms in docs.)
> 
> If I understood correctly, it is possible to fetch object (value) by 2i in 
> one time. But, we have tried using "return_term = true", it returns the index 
> with key comparing only key when not using "return_term=true".  It doesn't 
> help much with extra index, what we want to achieve is to fetch the object in 
> one time.
> 
> 
> Our use case,  client search DB every 10 seconds by 2i, Riak will return a 
> list of around 5000 results(Keys), then client will query DB to fetch value 
> for each key, basically it is around 5000 times,  client is easy to run into 
> some issues most of the time. Any suggestion here ?  
> 
> Many thanks in advance.
> 
> Br,
> Alex
> 
> 2017-02-06 19:02 GMT+08:00 Alex Feng <[email protected]>:
> Hi Russell,
> 
> It is really helpful, thank you a lot.
> We are suffering from solr crash now, are considering to switch to 2i.
> 
> Br,
> Alex
> 
> 2017-02-06 16:53 GMT+08:00 Russell Brown <[email protected]>:
> It’s worth noting that secondary indexes (2i) has some other advantages over 
> solr search. If you _can_ model your queries in 2i then I'd recommend it.
> 
> Secondary indexes  have a richer API than is currently documented, if you 
> look at https://docs.basho.com/riak/1.4.7/dev/using/2i/ you’ll see that 
> documents a feature that allows the index terms to be filtered via reg ex. 
> There is also the feature that can return the actual riak objects for a $keys 
> index search,
> You can pack the index terms with data and return the terms in a query so 
> that you don’t need a further object fetch (see return_terms in docs.)
> Secondary indexes are written atomically with the object they index.
> Operationally they don’t require you run a JVM and Solr alongside your riak 
> nodes.
> 
> You have the tools with basho_bench to answer the question about performance 
> and overhead for your workload. I suspect for “overhead” 2i wins, as there is 
> no JVM-per-node.
> 
> Modelling for 2i is perhaps harder, in the classical nosql way, you have to 
> do more work upfront when designing your querying.
> 
> I hope that helps a little. I worked quite a lot on 2i and never really 
> understood why riak-search was seen as a replacment, imo they’re 
> complementary, and you pick the one that best fits.
> 
> Cheers
> 
> Russell
> 
> On 2 Feb 2017, at 09:43, Alex Feng <[email protected]> wrote:
> 
> > Hello Riak-users,
> >
> > I am currently using Riak search to do some queries, since my queries are 
> > very simple, it should be fulfilled by secondary indexes as well.
> > So, my question is which one has better performance and less overhead, 
> > let's say both can fulfill the query requirement.
> >
> > Many thanks in advance.
> >
> > Br,
> > Alex
> > _______________________________________________
> > riak-users mailing list
> > [email protected]
> > http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
> 
> 
> 


_______________________________________________
riak-users mailing list
[email protected]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com

Reply via email to