Docs Home → View & Analyze Data → Spark Connector
Write to MongoDB in Batch Mode
Overview
Warning
Save Modes
The MongoDB Spark Connector supports the following save modes:
append
overwrite
If you specify the overwrite
write mode, the connector drops the target
collection and creates a new collection that uses the
default collection options.
This behavior can affect collections that don't use the default options,
such as the following collection types:
Sharded collections
Collections with nondefault collations
Time-series collections
To learn more about save modes, see the Spark SQL Guide.
Important
If your write operation includes a field with a null
value,
the connector writes the field name and null
value to MongoDB. You can
change this behavior by setting the write configuration property
ignoreNullValues
.
For more information about setting the connector's write behavior, see Write Configuration Options.
API Documentation
To learn more about the types used in these examples, see the following Apache Spark API documentation: