I have requirement to filter document in mongodb using spring data which contains nexted arrays of arrays. I am using following aggregation query on mongo shell and it is working fine. But when I am firing that through springdata aggregation operation, I am gettin empty response. Working mongo query is:
db.searchResource.aggregate({$match:{"_id" : ObjectId("53cf4e3dae92ac6561807f6d")}},{$project:{"rssSearchResponse.journeys":1}},{$unwind : "$rssSearchResponse.journeys"},{$match:{"rssSearchResponse.journeys.stops":0}});
Spring data code which I am using and s not working:
TypedAggregation<SearchResource> aggregation = Aggregation.newAggregation(SearchResource.class, Aggregation.match(new Criteria("_id").is(new ObjectId(searchId))),
Aggregation.project("rssSearchResponse.journeys"),
Aggregation.unwind("rssSearchResponse.journeys"),
Aggregation.match(new Criteria("rssSearchResponse.journeys.stops").is(0))
);
AggregationResults<SearchResource> result = mongoOperations.aggregate(aggregation, JourneyInformation.class);
I have tried breaking this aggregate function and it is able to project rssSearchResponse.journeys but after $unwind it returns empty result.
Any help is highly appreciated.