Link between documents


I have interlinked two documents say User profile(main document) with his friends list(sub document).
“friends_list”:["friend_01,…]} and

Now, I have to retrieve data using GET METHOD(JAVA)…I tried using GETBULK but dont know how to use the equivalent for:

beer = client.get(“beer:A_cold_one”);
comments = client.multiGet(beer.comment_ids)
in java???

I would suggest that. You just add the list of friends into the document as an Array. From there you can map/reduce to find particular friends.

Thanks for your reply. But am new to map/reduce function. If i insert my friends list in same document(it will be an performance issue)? bcoz my friends list will be keep on growing. So, i thought keeping it in separate document will be good…Any suggestions pls.

so I’ll break it down into two parts 1. Sample Json of user and friends. 2 . basic map/reduce job.

So we “Sara Tiller” and she has 2 friends… Mark Smith , and Ted Rogers.

“UserName”:“Sara Tiller”,
“Friends”:[“Mark Smith”,“Ted Rogers”]

2.a Now the Map/reduce…
We want to make sure that the document has a UserName and that the array is not empty

function(doc,meta){ if(doc.UserName && doc.Friends.length >0)


2.b looping through the list/array of friends and making an index(i.e. Map/reduce)

function(doc,meta){ if(doc.UserName && doc.Friends.length > 0){ for( var x in doc.Friends){ emit(doc.UserName,x); } } }

The output of this will look something like this.“Sara Tiller”&reduce=false

{“key”:“Sara Tiller”,“value”:“Mark Smith”},
{“key”:“Sara Tiller”,“value”:“Ted Rogers”},

Thank you for your valuable comment. Now, i can able to retrieve Friends list of a user(You gave clear idea) . I want to know

  1. Whether I can be able to retrieve friends list of two particular users(Sending parameter(username) to map function from sdk)
  2. Or I have to write two views for each user to get their friends list.
    Am trying to find mutual friends between two users. So I have to get friendslist of two users and have to compare it. Any Suggestions or idea???

You can pass mutiple keys to get your result like below.[“Sara Tiller”,“Jason Cribs”]&reduce=false .

To get more examples go to