Hi,

Thanks for your quick reply. Yes we tried to go through a Write like this
as specified in the documentation, but apparently it is only possible to
create a new document, not to update an existing one. Indeed, in case of an
existing ObjectId, there is no overwrite but a key violation.

*Caused by: com.mongodb.MongoBulkWriteException: Bulk write operation error
on server localhost:27017. Write errors: [BulkWriteError{index=0,
code=11000, message='E11000 duplicate key error collection:
flux_basa_test.sub_types index: _id_ dup key: { _id:
ObjectId('5e82086ea0d71a6e0cb4fccd') }', details={ }}]*

There doesn't seem to be any "drop and create" operation either. Perhaps we
are doing it wrong? Any idea?

Regards,
Emilien Henon

On Wed, Apr 1, 2020 at 9:48 AM Guillaume PEREZ <[email protected]>
wrote:

>
> ---------- Forwarded message ---------
> From: Jean-Baptiste Onofre <[email protected]>
> Date: Tue, Mar 31, 2020 at 6:07 PM
> Subject: Re: Question about updating documents on MongoDB
> To: dev <[email protected]>
> Cc: Guillaume PEREZ <[email protected]>, Pierre Alexandre
> Adamski <[email protected]>
>
>
> Hi,
>
> Not sure I understand fully your use case, but you can add/update document
> with Write:
>
> pipeline
> .apply(...)
> .apply(MongoDbIO.write()
> .withUri("mongodb://localhost:27017")
>     .withDatabase("my-database")
> .withCollection("my-collection")
> .withNumSplits(30))
>
> It’s using the Java SDK. Your question is specifically to Python ?
>
> Regards
> JB
>
> Le 31 mars 2020 à 11:32, Emilien HENON <[email protected]> a
> écrit :
>
> Hello,
>
> I would like to contact you concerning a question about the MongoDBIO
> connector. As part of our Dataflow / Apache Beam project, we need to create
> and update documents in our MongoDB database. However, the update operation
> seems impossible with the current connector (either we read or we create,
> but it seems impossible to modify/overwrite a document from an already
> existing ObjectId).
>
> We would have liked to know if it was really impossible to update or
> overwrite a document with this library (because according to the
> documentation, it seems possible on the Python side). If it is, is it a
> deliberate choice on your side? Or would it be possible to open an
> associated Jira to possibly contribute to an implementation?
>
> Regards,
> Emilien Henon
>
>
>

Reply via email to