Description
Using spring-data-mongodb 3.1.2, my repo looks like:
@Repository
public interface AirBnbRepository extends MongoRepository<Listing, String>,
QuerydslPredicateExecutor<Listing> {
}
The doc has a field thats a string array:
"amenities": ["TV", "Cable TV",
I'm trying to build a dynamic query with dsl, so something like:
BooleanBuilder builder = new BooleanBuilder();
if ((amenities != null) && (amenities.length > 0))
builder.and(QListing.listing.amenities.in(amenities));
This resulted in: find using query: { "amenities" : ["Wifi2"]}, which is wrong since its missing the whole $in portion. I stepped through the code and found there is a code path in there that if you have only 1 element, you change it to an eq. So I tried 2. I also tried bypassing the whole thing with:
builder.and(Expressions.booleanOperation(Ops.IN, QListing.listing.amenities, ConstantImpl.create(amenities)));
and got the same result. No $in.
How can we get the $in to work on an array with a dynamic query at runtime? I do also need to have pageable support :).
Thanks.