简体   繁体   中英

How to query mongodb with query Builder in java?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM