Java ~ MongoDB ~ Insert / Update bulk Doc's Help needed.

20 views
Skip to first unread message

N.S.KARTHIK

unread,
May 15, 2018, 5:29:32 AM5/15/18
to mongodb-user

Hi

 Spec : Java 1.8 , Mongo-Java Driver 3.6.

  Problem :  I Have a Big Collection of Documents  in MongoDB  .

                   I need a process to Insert OR Update  Documents , with-out any prior knowledge if the document exists  or  has changed or not  in the MongoDb Collection.


                   I tried using 'Upsert' in java code and was not successful :)
   
 With regards
Karthik         

Wan Bachtiar

unread,
May 17, 2018, 3:14:56 AM5/17/18
to mongodb-user

I tried using ‘Upsert’ in java code and was not successful

Hi Karthik,

Could you elaborate on what do you mean by ‘not successful’ ?

Could you provide:

  • The snippet code that you have tried
  • The error message that you’re seeing (if any)
  • What went wrong and what’s the desired effects.

Please see Tutorials: Bulk Writes for an example how to perform a bulk operations using the MongoDB Java Driver. You can specify UpdateOptions to specify that an operation is an upsert. See also com.mongodb.client.model.UpdateOptions

Regards,
Wan.

Reply all
Reply to author
Forward
0 new messages