Skip to main content

PutMongo

Description​

Writes the contents of a FlowFile to MongoDB

Tags​

insert, mongodb, put, update, write

Properties​

In the list below required Properties are shown with an asterisk (*). Other properties are considered optional. The table also indicates any default values, and whether a property supports the NiFi Expression Language.

Display NameAPI NameDefault ValueAllowable ValuesDescription
Client Servicemongo-client-serviceController Service:
MongoDBClientService

Implementations:
MongoDBControllerService
If configured, this property will use the assigned client service for connection pooling.
Mongo Database Name *Mongo Database NameThe name of the database to use

Supports Expression Language, using FlowFile attributes and Environment variables.
Mongo Collection Name *Mongo Collection NameThe name of the collection to use

Supports Expression Language, using FlowFile attributes and Environment variables.
Mode *Modeinsert
  • insert
  • update
Indicates whether the processor should insert or update content
Upsert *Upsertfalse
  • true
  • false
When true, inserts a document if no document matches the update query criteria; this property is valid only when using update mode, otherwise it is ignored

This property is only considered if:
  • the property Mode has a value of update
Update Query KeyUpdate Query KeyOne or more comma-separated document key names used to build the update query criteria, such as _id

Supports Expression Language, using FlowFile attributes and Environment variables.

This property is only considered if:
  • the property Mode has a value of update
Update Queryputmongo-update-querySpecify a full MongoDB query to be used for the lookup query to do an update/upsert. NOTE: this field is ignored if the 'Update Query Key' value is not empty.

Supports Expression Language, using FlowFile attributes and Environment variables.

This property is only considered if:
  • the property Mode has a value of update
Update Mode *put-mongo-update-modeWith whole document
  • With whole document
  • With operators enabled
Choose an update mode. You can either supply a JSON document to use as a direct replacement or specify a document that contains update operators like $set, $unset, and $inc. When Operators mode is enabled, the flowfile content is expected to be the operator part for example: {$set:{"key": "value"},$inc:{"count":1234}} and the update query will come from the configured Update Query property.

This property is only considered if:
  • the property Mode has a value of update
Update MethodUpdate MethodUpdate One
  • Update One
  • Update Many
  • Use 'mongodb.update.mode' FlowFile attribute.
MongoDB method for running collection update operations, such as updateOne or updateMany

This property is only considered if:
  • the property Update Mode has a value of operators
Character Set *Character SetUTF-8The Character Set in which the data is encoded

Dynamic Properties​

This component does not support dynamic properties.

Relationships​

NameDescription
failureAll FlowFiles that cannot be written to MongoDB are routed to this relationship
successAll FlowFiles that are written to MongoDB are routed to this relationship

Reads Attributes​

This processor does not read attributes.

Writes Attributes​

NameDescription
mongo.put.update.match.countThe match count from result if update/upsert is performed, otherwise not set.
mongo.put.update.modify.countThe modify count from result if update/upsert is performed, otherwise not set.
mongo.put.upsert.idThe '_id' hex value if upsert is performed, otherwise not set.

State Management​

This component does not store state.

Restricted​

This component is not restricted.

Input Requirement​

This component requires an incoming relationship.

System Resource Considerations​

ScopeDescription
MEMORYAn instance of this component can cause high usage of this system resource. Multiple instances or high concurrency settings may result a degradation of performance.

See Also​