You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@beam.apache.org by "Deepal Neema (Jira)" <ji...@apache.org> on 2022/04/06 10:53:00 UTC

[jira] [Comment Edited] (BEAM-12400) Improve MongoDBIO for beam - add update capability

    [ https://issues.apache.org/jira/browse/BEAM-12400?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17518029#comment-17518029 ] 

Deepal Neema edited comment on BEAM-12400 at 4/6/22 10:52 AM:
--------------------------------------------------------------

Hello Team, 

I have a similar kind of issue where i am trying to upsert based on two fields i.e *vin* and *key* other than {*}_id{*}, i don't have *_id* field as this is dynamically(automated) generated, so when ever i have the new document i want to check with my filter keys if it's there it should update the existing one if not insert a new one. using below code i am trying to do this:

MongoDbIO.write()
    .withUri(options.getMongoDBHostName())
    .withDatabase(options.getMongoDBDatabaseName())
    .withCollection(collection)
    .withUpdateConfiguration(UpdateConfiguration.create()
                                .withIsUpsert(true)
                                .withUpdateKey("vin")
                                .withUpdateKey("key")
                                .withUpdateFields(
                                        UpdateField.fieldUpdate("$set", "vin", "vin"),
                                        UpdateField.fieldUpdate("$set", "key", "key"),
                                        UpdateField.fieldUpdate("$set", "timestamp", "timestamp"),
                                        UpdateField.fieldUpdate("$set", "value", "value")
                                        )                                       
                                )
                                
                        );

 

Here when i am trying to do this it's not creating *_id* field dynamically and creating *_id* field same as *key* field

 

What should i do to avoid creating new _id field or how to handle this ?


was (Author: JIRAUSER287688):
Hello Team, 

I have a similar kind of issue where i am trying to upsert based on two fields i.e *vin* and *key* other than {*}_id{*}, i don't have *_id* field as this is dynamically(automated) generated, so when ever i have the new document i want to check with my filter keys if it's there it should update the existing one if not insert a new one. using below code i am trying to do this:

MongoDbIO.write()
    .withUri(options.getMongoDBHostName())
    .withDatabase(options.getMongoDBDatabaseName())
    .withCollection(collection)
    .withUpdateConfiguration(UpdateConfiguration.create()
                                .withIsUpsert(true)
                                .withUpdateKey("vin")
                                .withUpdateKey("key")
                                .withUpdateFields(
                                        UpdateField.fieldUpdate("$set", "vin", "vin"),
                                        UpdateField.fieldUpdate("$set", "key", "key"),
                                        UpdateField.fieldUpdate("$set", "timestamp", "timestamp"),
                                        UpdateField.fieldUpdate("$set", "value", "value")
//                                        UpdateField.fullUpdate("$push", documentFromDeletePardo.toString())
                                        )
//                                        
                                )
                                
                        );

 

Here when i am trying to do this it's not creating *_id* field dynamically and creating *_id* field same as *key* field

> Improve MongoDBIO for beam - add update capability
> --------------------------------------------------
>
>                 Key: BEAM-12400
>                 URL: https://issues.apache.org/jira/browse/BEAM-12400
>             Project: Beam
>          Issue Type: Improvement
>          Components: io-java-mongodb
>            Reporter: Paresh Saraf
>            Assignee: Paresh Saraf
>            Priority: P2
>             Fix For: 2.34.0
>
>   Original Estimate: 168h
>          Time Spent: 8h 40m
>  Remaining Estimate: 159h 20m
>
> Right now mongodbio supports only inserts/overwrites to a collections. In many cases it will be usually updating an existing document: setting a field or pushing into an array. BulkUpdate capability to be added as part part of MongoDBIo->Write



--
This message was sent by Atlassian Jira
(v8.20.1#820001)