How to create Dynamic View

100 views
Skip to first unread message

Gopinath Navaneethan

unread,
Jan 2, 2014, 7:21:34 AM1/2/14
to couc...@googlegroups.com
Hi All,
            I am having a bucket with different Tenant Id. Now I need to get the data using view depends on the tenant. It has to give me the particular details of the tenant. Is this possible to create a dynamic view.

If i try to get the details of document which belongs to tenant id =1. Then i have to get all the Documents in the Bucket and i have to find tenant having the id as 1.
Instead of this I want to create a view dynamic if I give id as 1 it could give data which having the tenant 1 or if I give id as 2 it could give data which having the tenant 2 is this is possible.


Thanks
Gopi.

Andrew W. Donoho

unread,
Jan 2, 2014, 9:11:13 AM1/2/14
to couc...@googlegroups.com, Gopinath Navaneethan
Gopi,



A perhaps better question is: what are you really trying to do?

I ask because it appears you are thinking of Couchbase views like they are SQL indices (with which they share some behavior). Thinking this way both underutilizes the view's capabilities and will keep you from learning how to model your data as appropriate for a document database. A document database with nested documents is not a relational database; one models one's data differently.

Why do you want a dynamic view? Dynamism always has a cost that exceeds the cost of static, compiled/indexed, routine behavior. Why do you want to pay that cost?

The short answer is that it isn't practically possible to create a dynamic view. The long answer is you can create such a view yourself by reading every document. You typically don't want to do this. In my case, my test database has almost 100M documents and exceeds 90GB in size. Just reading every bit of it at wireline speeds takes over 30 minutes (datapoint taken from the time it takes CB to warm up on this DB from a cold start). IOW, I could never afford to pay the dynamic cost. If your database is of any size, I doubt you can either.



Anon,
Andrew
____________________________________
Andrew W. Donoho
Donoho Design Group, L.L.C.
andrew...@gmail.com, +1 (512) 666-7596, twitter.com/adonoho

Download Retweever here: <http://Retweever.com>

No risk, no art.
No art, no reward.
-- Seth Godin



Marélette van Dalen

unread,
Jul 3, 2014, 6:06:39 AM7/3/14
to couc...@googlegroups.com, ngopi...@gmail.com
How exactly do I query then? If I'm using java to query the server, and I ask a user to enter a parameter, how do I create a view to return all the documents with that parameter? I figured I'd create a "mapFunction" in Java, and then create / overwrite a view to return. I can't seem to get this to work though.
Reply all
Reply to author
Forward
0 new messages