I would like to use Spring Data Mangodebi for this aggregation query. {"$ Group": {"_id": "$ searchTerm", "dateAddToSet": {"$ addToSet": "$ date"}}}, {"$ project" : {"SearchTerm": "$ _id.searchTerm", "percent": {"$ divide": [{"$ size": "$ dateAddToSet"}, 28]}}})
I can not
Thank you very much ago. Sorry for the delay here is the main problem that Spring Mongo is not a supported operation at this time. . So the only way to build is to use the construction of DBOBK.
But you can add two methods by providing your own wrapper class, such as:
Public class customization operation Tools Integration Operation {Personal DBObject Operation; Public Castelagration Operation (DBOBject operation) {this.operation = Operation; } Override @DOBiBeject public DobBeject (aggregation option reference) {reference context.getMappedObject (operation); }}
Therefore, to override the .toDBObject ()
method in general, simply return the DBObject
data which is used by the constructor
Then use it later in the creation of your aggregation:
aggregation agg = newAggregation (group ("searchTerm New add-ons ("dateAddToSet"), new CustomAgreement Operations ("$ Project", New BasicDBObject ("_ id", 0) .append ("searchTerm", "$ _ id") .append ("percent" , The new BasicDBObject ("$ partition", new object [] {New BasicDBObject ("$ size", "dateAddToSet"), 28})))));
and it produces a pipeline with the correct form:
{"total": " __collection__ "$ group": ["$ group": {"_id": "$ searchTerm", "dateAddToSet": {"$ addToSet": "$ date"}}}, {"$ project": {"_id" :, "SearchTerm": "$ _id", "percent": {"$ divide": [{"$ size": "$ dateAddToSet"}, 28]}}}]}
So there is a way of mixing available builders with custom build so that you can use those methods where no builder is present.
No comments:
Post a Comment