If you want to perform some kind of ad hoc querying, your only real option is
Map Reduce. Fun fact: you can perform Riak Search queries through Map Reduce.
You can also do this with HTPP requests for Riak Search or indexes (either HTTP
or Protocol Buffers), but you'll probably end up doing something that looks
like this:
Query objects from Riak Search
Collect relationship IDs from Riak Search results
Query objects from Riak or Riak Search by ID
Repeat
Depending on your application patterns, it's possible to save the complete
object graph in Riak. Riak is ill-suited to ad hoc querying patterns like you
can perform on an RDBMS.
A good pattern for this comes from orders. In an RDBMS you might have tables to
define OrderHeaders, LineItems, Customers, and Addresses. With riak you could
easily save this as an object graph that looks like this:
{ order_header: { blah blah blah },
line_items: [],
customer: { blah blah blah },
shipping_address: { blah blah blah },
billing_address: { blah blah blah }
}
Data modeling in Riak typically requires that you flatten your data model when
you save it: optimize for reads, not writes.
If you have a predictable key name format, you can use key filters to perform
an in-memory query on key names before performing your MR queries on the
results of the key filter.
Without knowing more about what you're actually trying to accomplish, it's not
possible to provide you with an accurate and detailed answer; I can only give
you generalities and hand waving. It may be that you aren't able to give that
info out on a mailing list, and I completely understand that.
---
Jeremiah Peschka - Founder, Brent Ozar PLF, LLC
Microsoft SQL Server MVP
On Sep 28, 2011, at 2:29 PM, Harshal Dhir wrote:
>
> Hi Jeremiah,
>
> Thanks for your quick response. But, we also want to do a query on the
> bucket, so yes implementing links if you want to pull one object makes
> sense, but if you want to do query. Only way to do this to use MapReduce.
>
> Please correct me if I am wrong.
>
>
> Harshal Dhir | Technical Architect
>
> solutionset
>
> P: 510-214-3519 Twitter: @harshaldhir
>
> 85 Second Street, San Francisco, CA 94105
>
> Twitter: @harshaldhir MSN: [email protected] Jabber:
> [email protected]
> www.solutionset.com <http://www.solutionset.com/>
>
> This message is intended for the addressee(s) only and may contain
> confidential or privileged
> information. Any use of this information by persons other than
> addressee(s) is prohibited. If you
> have received this message in error, please reply to the sender and delete
> or destroy all copies.
>
>
>
>
>
>
>
>
> On 9/28/11 11:17 AM, "Jeremiah Peschka" <[email protected]> wrote:
>
>> You can link walk without MapReduce - the RpbContent object returned by
>> the ProtocolBuffers API should include the immediate level of links.
>> Otherwise, many clients support using HTTP requests to perform link walks
>> of arbitrary depths.
>>
>> The bigger question is: what are you trying to accomplish?
>>
>> ---
>> Jeremiah Peschka - Founder, Brent Ozar PLF, LLC
>> Microsoft SQL Server MVP
>>
>> On Sep 28, 2011, at 2:08 PM, Harshal Dhir wrote:
>>
>>> Hi folks,
>>>
>>> We were just wondering what is the best possible way to model 1 N
>>> relationships in Riak. We know that there are links but the mapreduce is
>>> too slow. So, we moved towards using RiakSearch but it seems that
>>> modeling relationships and having lists in riak search KV object doesn't
>>> quiet do the job.
>>>
>>> So, we were looking for some guidance on this front.
>>>
>>> Thanks
>>> Harshal
>>>
>>>
>>> _______________________________________________
>>> 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