'Specify raw aggregate request with Spring Data Mongodb

I write a big aggregate query for mongodb, now I try to translate it in Spring Data Mongodb API, and it's very complicated, and spring data api did not help me a lot.

So like with @Query annotation, is it possible to just specify my raw aggregate query in text and map my field with Spring Data (or just Mongodb Java driver) ?

I won't c/p my aggregate request because, it's not the purpose of my question.



Solution 1:[1]

I found a solution by using MongoDB java driver, which is available through Spring Data :

DBCollection collection = mongoTemplate.getCollection("myCollection");

and I used BasicDBObject from this solution : MongoDB aggregation with Java driver

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1