How to retrieve documents with Spring Data and @Query annotation from multiple collections?


The Repository looks like this

public interface RoutesRepository extends CouchbaseRepository<Routes, String> {

I want to do something like this:

FROM `_default`.`_default`.`routes` r
WHERE r.routeId IN
(SELECT RAW p.routeId
FROM `_default`.`_default`.`routeToCustomerRelations` p
WHERE p.zipCodes = 11223344);

How can this be translated to SpEL for inside the @Query(…) annotation?

@Query("SELECT meta(my_bucket.my_scope.my_collection).id as __id, meta(my_bucket.my_scope.my_collection).cas as __cas, my_bucket.my_scope.my_collection.*
FROM my_bucket.my_scope.my_collection r
WHERE r.routeId IN
(SELECT RAW p.routeId
FROM my_bucket.my_scope.my_collection2 p
WHERE p.zipCodes = $1))
List<Routes> getByZipCode( String zipCode)