I use Spring Data DSL to query MongoDB in the following way:
Page<Member> findByCommunitiesCodeContaining(String code, Pageable pageable);
It returns all Members of a community with a given code.
Problem: I need to pass a collection of community codes and return Members that participate in at least one community from the listed codes (where intersection of communities is not empty).
I browsed the Spring Data Mongo documentation but couldn't find a DSL supporting this case.
Question: How do I query records with intersection of collections?
More details. Here is how my structure looks on Java side.
@Document
public class Member {
@Id
private String id;
private List<Community> communities;
}
Community:
public class Community {
private String region;
private String code;
}