SELECT ARRYA_FLATTEN(ARRAY (ARRAY u1.rhsId FOR u1 IN d2.entityRelations WHEN u1. lhsId = v1.id END) FOR v1 IN d. entities WHEN v1.name = "foo" END,2)
FROM default AS d USE KEYS "doc1"
LET d2 = (SELECT d2.* FROM default AS d2 USE KEYS "doc2")
Thanks for the quick response.
The problem is a little more complex, which I should have been more clear on.
The join I want to perform on is on two different result sets obtained from two different queries. So the documents (1)entities and (2) entityRelations are a result of some other N1QL query(See rephrased question below)
I have 3 entity documents and 2 relationship documents
(ARRAY u1.rhsId FOR u1 IN entityRelations WHEN u1. lhsId = v1.id END)
FOR v1 IN entities WHEN v1.name = "foo" END,2)
LET entityRelations = (Sub query),
entities = (SUB query);
One question though. Does this mean two separate queries are performed by couchbase and the result sets are later merged.
Or does couchbase optimise it by using the results of the entities sub query in the entityRelations subquery.