Fetch details from one document based on a field from other document in the same bucket

Hello People,
I am a rookie in couchbase and N1QL. Recently I’ve encountered a scenario where I should fetch some details from one document based on a field that’s coming from other document within the same bucket. For example , consider that below are my documents,
doc_type : product
productid : PRE1234
feetype: ABC

I should now fetch productid from document1 where feetype = the feetype from document 2. In SQL, I could write the query like below.
Select productid from ‘bucket’ b where b.doc_type=product and b.feetype= (select feetype from ‘bucket’ a where a.doc_type=fee). I cannot use joins are this is not a primary key. It would be great if you could let me know of any suggestions?


SELECT productid FROM `bucket` b WHERE b.doc_type = product AND b.feetype IN
           (SELECT RAW Feetype FROM `bucket` a FROM WHERE a.doc_type = fee);