how to perform below operation (it is the actual mongo query) using MatchOperation in Spring data mongodb ?
$match: { "docs": { $ne: [] } }
here docs is an array field and want to check that it is not empty.
how to perform below operation (it is the actual mongo query) using MatchOperation in Spring data mongodb ?
$match: { "docs": { $ne: [] } }
here docs is an array field and want to check that it is not empty.
I also had a similar problem, but I solved is as below.
MatchOperation mathOpertaion = match(Criteria.where("docs") .elemMatch(new Criteria().exists(true)));
You can use .not
Criteria.where("arr").not().size(0)
© 2022 - 2025 — McMap. All rights reserved.
Aggregation aggregation = Aggregation.newAggregation( Aggregation.match(Criteria.where("docs").exists(true)));
– UnloosenAggregation aggregation = Aggregation.newAggregation(Aggregation.match(Criteria.where("docs").ne(Collections.EMPTY_LIST)));
– UnloosenAggregation aggregation = Aggregation.newAggregation(Aggregation.match(Criteria.where("docs").ne(Collections.EMPTY_LIST)));
– Bertine