Closed spring-projects-issues closed 4 years ago
Christoph Strobl commented
I might be wrong but judging from the given snippets, it looks like you're directly using MongoDB driver API from the com.mongodb.client.model
namespace to create the pipeline.
Can you share how the pipeline is executed?
samueldedavid commented
I use it like this . I could not find a lot of documentation about it.
List<Bson> pipeline = Arrays.asList(
match(and(eq("pdg", "PD"), eq("type", "type1"),
and(gte("date", "2019-01-01"), lte("date", "2019-12-01")))),
sort(orderBy(ascending("pdg"), ascending("date"))),
group(eq("site", "$site"),
push("wf", and(eq("site", "$site"), eq("date", "$date"), eq("resources", "$resources"))),
sum("tresources", "$resources")),
match(gt("tresources", 0L)));
List<Document> result =
template.getCollection("sample").aggregate(pipeline).into(new ArrayList<Document>());
Christoph Strobl commented
Thanks for sharing, everything past template.getCollection("sample")
is MongoDB driver API. Please report issues with the driver at jira.mongodb.org
samueldedavid commented
Christoph Strobl Ok Thanks
samueldedavid opened DATAMONGO-2583 and commented
Mongo Pipeline
Output from Mongo Query is in the attached file view.json
Output from Java aggregates framework is
The problem is that the collected items in the group are returned as True and False which is not correct and also not what is produced when using this pipeline in shell . I have no other option but to post it here as a bug . Currently I am using
@aggregates
to do this operation. Also It would be nice to pass the pipeline array as a single string in aggregation parameter. Currently I break the pipeline above and add it as@aggregation
(pipeline={p1,p2,p3...pn})Reference URL: https://developer.mongodb.com/community/forums/t/compass-pipeline-export-to-java-not-producing-same-results/6362
Attachments: