What is the best way to get referenced data

In my app i have 2 fields which are buckets and category’s and which a contact can be associated with. Rather then storing the name of bucket or category i store the bucket or category docid.

 "categories": [
	 "buckets": [

so what is the best approach to be able to get the name field of these bucket and category doc’s ? would it make sense to use a join and join these or would a sub query the better solution ? To keep in mind i am also going to use this when creating a list so there might be 100 contacts per page which could have 1 to 10 bucket keys and or category keys so we are talking possibly 1000 sub queries or joint.

for now i am using something like this

(SELECT text, meta().id as DocId
FROM `Contacts`
USE KEYS d.buckets) AS buckets

wondering if this is the best approach ?

It all depends on format of your output.

If you want Array of categories and array of buckets use subquery

     SELECT   (SELECT c.text, meta(c).id as DocId  FROM `Contacts`  AS c USE KEYS d. categories) AS categories
                          (SELECT b.text, meta(b).id as DocId  FROM `Contacts`  AS b USE KEYS d.buckets) AS buckets
     FROM .....
    WHERE ....

If you want separate documents use JOIN.