I need to make a query in java to MongoDB, how could I do it with QueryBuilder, this is my query:
db.c_chm8_transactionality.aggregate([ { "$match":{ "$or":[ { "$or":[ { "gf_customer_id":"002168855" }, { "gf_customer_id":"009507458" } ] }, { "$and":[ { "gf_cutoff_date":{ "$gte":new Date(2000-08-07) } }, { "gf_cutoff_date":{ "$lte":new Date(2020-08-07) } } ] } ] } }, { "$group":{ "_id":{ "gf_product_type_desc":"$gf_product_type_desc", "gf_channel_subtype_id":"$gf_channel_subtype_id", "gf_cutoff_date":"$gf_cutoff_date" }, "transaccionTotal":{ "$sum":"$gf_monthly_transactions_number" } } } ]);
By the way, if anyone knows where I can find documentation to make these queries, I would appreciate it.
Advertisement
Answer
You should Refer this documentation
Create a MongoCollection
object.
Create a list
to have aggregate pipelines
Aggregates
is a class where you will have all valid pipelines.
Pass the list to aggregate
function of the MongoCollection
object.