N1QL Doesn’t support CONNECT BY. You can check out this post and see if helps in what you are looking for N1QL - array join