I have this Json: I would like to filter exclusive for paymentType.type equals “PILOT” and limits equals type equals “COMBAT_HOURS”. This is the result I would like to receive. How to extract the document to reach this result? Answer Query map paymentTypes if paymentType= PILOT, filter the limits to keep only the combat hours else null (we don’t want that
Tag: aggregation-framework
MongoDB Aggregation Pipeline – Count no of records that are matching a complex criteria – (Couldn’t find PersistentEntity for type java.lang.Object!)
I have documents with dynamic fields and I would need to find a count of matching records for a given complex query criteria Example Entity Example Data: Expected Query Criteria: Building such complex Criteria using $match would be too much of implementation, so I was trying to use SPEL evolution through $project like below: However, the above logic failing due
How to custom sort only specific results in Spring MongoDB?
Is it possible to sort only results that matches a condition in Spring Mongo? Let us say I have this data: Color Fruit Amount Orange Orange 23 Red Apple 4 Red Strawberry 66 Yellow Banana 2 I want to sort the list to display the Fruits with color red on Top and the remaining fruits will be sorted by amount.
How to count array elements properly with multiple aggregation in Spring Data MongoDB?
I need to create advanced aggregation using Spring Data MongoDB having model like that: pom.xml Cities collection: Libraries collection: Books collection: Depending on the context of the user, I have to return cities with count of libraries and books in the city that can be filtered based on startsWith() or like() principle. Assuming that I have 2 libraries in one
Aggregation with multiple criteria
I want to perform aggregation using multiple criteria. The problem is that I don’t know how to pass multiple criteria. Do I declare multiple Match operation like below? And if yes, then how do I pass them to the aggregation method? I thought that it should be possible to create a MatchOperation that adheres in multiple criteria but I have