Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for AggregationExpression in GroupOperation.sum [DATAMONGO-1784] #2693

Closed
spring-projects-issues opened this issue Sep 18, 2017 · 2 comments

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Sep 18, 2017

Sergey Shcherbakov opened DATAMONGO-1784 and commented

After this ticket has been implemented, it is possible to use complex expressions in the aggregation request projections and group method parameters.
For example, there are min(), max(), first() aggregation methods that accept AggregationExpression in the GroupOperation class.
But there is no sum() aggregation method version that accepts AggregationExpression parameter.
Thus, it is not possible to express following MongoDB queries using Spring Data fluent API:

[
     { $match: { "myfield":"X" },
     { $group: {
           _id: { myfield: "$myfield"  },
           count: { $sum: 1 },
           lt5w: { $sum: { $cond:{ if: { $gte: [ "$myDate", new Date(ISODate().getTime() - 1000 * 60 * 60 * 24 * 7 * 5) ] }, then: 1, else: 0 } } },
           gt12w: { $sum: { $cond:{ if: { $gte: [ new Date(ISODate().getTime() - 1000 * 60 * 60 * 24 * 7 * 12), "$myDate"  ] }, then: 1, else: 0 } } }
         }
     }
])

Affects: 1.10.8 (Ingalls SR8), 2.0 GA (Kay)

Referenced from: pull request #501

Backported to: 1.10.8 (Ingalls SR8)

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Sep 19, 2017

Sergey Shcherbakov commented

Submitted a PR for this
#501
It would be great it could be ported to the Spring Framework 4.0 1.10.x branch as well

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Sep 19, 2017

Christoph Strobl commented

Thanks Sergey! Will have a look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants