Blame SOURCES/mongoimport.1

334bcc
.\" Man page generated from reStructuredText.
334bcc
.
334bcc
.TH "MONGOIMPORT" "1" "January 30, 2015" "3.0" "mongodb-manual"
334bcc
.SH NAME
334bcc
mongoimport \- MongoDB Import Utility
334bcc
.
334bcc
.nr rst2man-indent-level 0
334bcc
.
334bcc
.de1 rstReportMargin
334bcc
\\$1 \\n[an-margin]
334bcc
level \\n[rst2man-indent-level]
334bcc
level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
334bcc
-
334bcc
\\n[rst2man-indent0]
334bcc
\\n[rst2man-indent1]
334bcc
\\n[rst2man-indent2]
334bcc
..
334bcc
.de1 INDENT
334bcc
.\" .rstReportMargin pre:
334bcc
. RS \\$1
334bcc
. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
334bcc
. nr rst2man-indent-level +1
334bcc
.\" .rstReportMargin post:
334bcc
..
334bcc
.de UNINDENT
334bcc
. RE
334bcc
.\" indent \\n[an-margin]
334bcc
.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
334bcc
.nr rst2man-indent-level -1
334bcc
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
334bcc
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
334bcc
..
334bcc
.SH SYNOPSIS
334bcc
.sp
334bcc
The \fBmongoimport\fP tool provides a route to import content from a
334bcc
JSON, CSV, or TSV export created by \fBmongoexport\fP, or
334bcc
potentially, another third\-party export tool. See the
334bcc
http://docs.mongodb.org/manual/core/import\-export document for a more in depth
334bcc
usage overview, and the \fBmongoexport\fP document for more
334bcc
information regarding \fBmongoexport\fP, which
334bcc
provides the inverse "exporting" capability.
334bcc
.SH CONSIDERATIONS
334bcc
.sp
334bcc
Do not use \fBmongoimport\fP and \fBmongoexport\fP for
334bcc
full instance, production backups because they will not reliably capture data type
334bcc
information. Use \fBmongodump\fP and \fBmongorestore\fP as
334bcc
described in http://docs.mongodb.org/manual/core/backups for this kind of
334bcc
functionality.
334bcc
.sp
334bcc
\fBmongoimport\fP is single\-threaded and inserts one document at
334bcc
a time into MongoDB. Custom import tools for data ingestion may have
334bcc
better performance for specific workloads.
334bcc
.SH OPTIONS
334bcc
.sp
334bcc
Changed in version 3.0.0: \fBmongoimport\fP removed the \fB\-\-dbpath\fP as well as related
334bcc
\fB\-\-directoryperdb\fP and \fB\-\-journal\fP options. You must use
334bcc
\fBmongoimport\fP while connected to a \fBmongod\fP instance.
334bcc
334bcc
.INDENT 0.0
334bcc
.TP
334bcc
.B mongoimport
334bcc
.UNINDENT
334bcc
.INDENT 0.0
334bcc
.TP
334bcc
.B mongoimport
334bcc
.UNINDENT
334bcc
.INDENT 0.0
334bcc
.TP
334bcc
.B \-\-help
334bcc
Returns information on the options and use of \fBmongoimport\fP\&.
334bcc
.UNINDENT
334bcc
.INDENT 0.0
334bcc
.TP
334bcc
.B \-\-verbose, \-v
334bcc
Increases the amount of internal reporting returned on standard output
334bcc
or in log files. Increase the verbosity with the \fB\-v\fP form by
334bcc
including the option multiple times, (e.g. \fB\-vvvvv\fP\&.)
334bcc
.UNINDENT
334bcc
.INDENT 0.0
334bcc
.TP
334bcc
.B \-\-quiet
334bcc
Runs the \fBmongoimport\fP in a quiet mode that attempts to limit the amount
334bcc
of output.
334bcc
.sp
334bcc
This option suppresses:
334bcc
.INDENT 7.0
334bcc
.IP \(bu 2
334bcc
output from \fIdatabase commands\fP
334bcc
.IP \(bu 2
334bcc
replication activity
334bcc
.IP \(bu 2
334bcc
connection accepted events
334bcc
.IP \(bu 2
334bcc
connection closed events
334bcc
.UNINDENT
334bcc
.UNINDENT
334bcc
.INDENT 0.0
334bcc
.TP
334bcc
.B \-\-version
334bcc
Returns the \fBmongoimport\fP release number.
334bcc
.UNINDENT
334bcc
.INDENT 0.0
334bcc
.TP
334bcc
.B \-\-host <hostname><:port>, \-h <hostname><:port>
334bcc
\fIDefault\fP: localhost:27017
334bcc
.sp
334bcc
Specifies a resolvable hostname for the \fBmongod\fP to which to
334bcc
connect. By default, the \fBmongoimport\fP attempts to connect to a MongoDB
334bcc
instance running on the localhost on port number \fB27017\fP\&.
334bcc
.sp
334bcc
To connect to a replica set, specify the
334bcc
\fBreplSetName\fP and a seed list of set members, as in
334bcc
the following:
334bcc
.INDENT 7.0
334bcc
.INDENT 3.5
334bcc
.sp
334bcc
.nf
334bcc
.ft C
334bcc
<replSetName>/<hostname1><:port>,<hostname2><:port>,<...>
334bcc
.ft P
334bcc
.fi
334bcc
.UNINDENT
334bcc
.UNINDENT
334bcc
.sp
334bcc
You can always connect directly to a single MongoDB instance by
334bcc
specifying the host and port number directly.
334bcc
.sp
334bcc
Changed in version 3.0.0: If you use IPv6 and use the \fB<address>:<port>\fP format, you must
334bcc
enclose the portion of an address and port combination in
334bcc
brackets (e.g. \fB[<address>]\fP).
334bcc
334bcc
.UNINDENT
334bcc
.INDENT 0.0
334bcc
.TP
334bcc
.B \-\-port <port>
334bcc
\fIDefault\fP: 27017
334bcc
.sp
334bcc
Specifies the TCP port on which the MongoDB instance listens for
334bcc
client connections.
334bcc
.UNINDENT
334bcc
.INDENT 0.0
334bcc
.TP
334bcc
.B \-\-ipv6
334bcc
Enables IPv6 support and allows the \fBmongoimport\fP to connect to the
334bcc
MongoDB instance using an IPv6 network. All MongoDB programs and
334bcc
processes disable IPv6 support by default.
334bcc
.UNINDENT
334bcc
.INDENT 0.0
334bcc
.TP
334bcc
.B \-\-ssl
334bcc
New in version 2.6.
334bcc
334bcc
.sp
334bcc
Enables connection to a \fBmongod\fP or \fBmongos\fP that has
334bcc
SSL support enabled.
334bcc
.sp
334bcc
The default distribution of MongoDB does not contain support for SSL.
334bcc
For more information on MongoDB and SSL, see http://docs.mongodb.org/manual/tutorial/configure\-ssl\&.
334bcc
.UNINDENT
334bcc
.INDENT 0.0
334bcc
.TP
334bcc
.B \-\-sslCAFile <filename>
334bcc
New in version 2.6.
334bcc
334bcc
.sp
334bcc
Specifies the \fB\&.pem\fP file that contains the root certificate chain
334bcc
from the Certificate Authority. Specify the file name of the
334bcc
\fB\&.pem\fP file using relative or absolute paths.
334bcc
.sp
334bcc
The default distribution of MongoDB does not contain support for SSL.
334bcc
For more information on MongoDB and SSL, see http://docs.mongodb.org/manual/tutorial/configure\-ssl\&.
334bcc
.sp
334bcc
\fBWARNING:\fP
334bcc
.INDENT 7.0
334bcc
.INDENT 3.5
334bcc
If the \fBmongo\fP shell or any other tool that connects to
334bcc
\fBmongos\fP or \fBmongod\fP is run without
334bcc
\fI\-\-sslCAFile\fP, it will not attempt to validate
334bcc
server certificates. This results in vulnerability to expired
334bcc
\fBmongod\fP and \fBmongos\fP certificates as well as to foreign
334bcc
processes posing as valid \fBmongod\fP or \fBmongos\fP
334bcc
instances. Ensure that you \fIalways\fP specify the CA file against which
334bcc
server certificates should be validated in cases where intrusion is a
334bcc
possibility.
334bcc
.UNINDENT
334bcc
.UNINDENT
334bcc
.UNINDENT
334bcc
.INDENT 0.0
334bcc
.TP
334bcc
.B \-\-sslPEMKeyFile <filename>
334bcc
New in version 2.6.
334bcc
334bcc
.sp
334bcc
Specifies the \fB\&.pem\fP file that contains both the SSL certificate
334bcc
and key. Specify the file name of the \fB\&.pem\fP file using relative
334bcc
or absolute paths.
334bcc
.sp
334bcc
This option is required when using the \fI\-\-ssl\fP option to connect
334bcc
to a \fBmongod\fP or \fBmongos\fP that has
334bcc
\fBCAFile\fP enabled \fIwithout\fP
334bcc
\fBallowConnectionsWithoutCertificates\fP\&.
334bcc
.sp
334bcc
The default distribution of MongoDB does not contain support for SSL.
334bcc
For more information on MongoDB and SSL, see http://docs.mongodb.org/manual/tutorial/configure\-ssl\&.
334bcc
.UNINDENT
334bcc
.INDENT 0.0
334bcc
.TP
334bcc
.B \-\-sslPEMKeyPassword <value>
334bcc
New in version 2.6.
334bcc
334bcc
.sp
334bcc
Specifies the password to de\-crypt the certificate\-key file (i.e.
334bcc
\fI\-\-sslPEMKeyFile\fP). Use the \fI\-\-sslPEMKeyPassword\fP option only if the
334bcc
certificate\-key file is encrypted. In all cases, the \fBmongoimport\fP will
334bcc
redact the password from all logging and reporting output.
334bcc
.sp
334bcc
If the private key in the PEM file is encrypted and you do not specify
334bcc
the \fI\-\-sslPEMKeyPassword\fP option, the \fBmongoimport\fP will prompt for a passphrase. See
334bcc
\fIssl\-certificate\-password\fP\&.
334bcc
.sp
334bcc
The default distribution of MongoDB does not contain support for SSL.
334bcc
For more information on MongoDB and SSL, see http://docs.mongodb.org/manual/tutorial/configure\-ssl\&.
334bcc
.UNINDENT
334bcc
.INDENT 0.0
334bcc
.TP
334bcc
.B \-\-sslCRLFile <filename>
334bcc
New in version 2.6.
334bcc
334bcc
.sp
334bcc
Specifies the \fB\&.pem\fP file that contains the Certificate Revocation
334bcc
List. Specify the file name of the \fB\&.pem\fP file using relative or
334bcc
absolute paths.
334bcc
.sp
334bcc
The default distribution of MongoDB does not contain support for SSL.
334bcc
For more information on MongoDB and SSL, see http://docs.mongodb.org/manual/tutorial/configure\-ssl\&.
334bcc
.UNINDENT
334bcc
.INDENT 0.0
334bcc
.TP
334bcc
.B \-\-sslAllowInvalidCertificates
334bcc
New in version 2.6.
334bcc
334bcc
.sp
334bcc
Bypasses the validation checks for server certificates and allows
334bcc
the use of invalid certificates. When using the
334bcc
\fBallowInvalidCertificates\fP setting, MongoDB logs as a
334bcc
warning the use of the invalid certificate.
334bcc
.sp
334bcc
The default distribution of MongoDB does not contain support for SSL.
334bcc
For more information on MongoDB and SSL, see http://docs.mongodb.org/manual/tutorial/configure\-ssl\&.
334bcc
.UNINDENT
334bcc
.INDENT 0.0
334bcc
.TP
334bcc
.B \-\-sslAllowInvalidHostnames
334bcc
New in version 3.0.
334bcc
334bcc
.sp
334bcc
Disables the validation of the hostnames in SSL certificates. Allows
334bcc
\fBmongoimport\fP to connect to MongoDB instances if the hostname their
334bcc
certificates do not match the specified hostname.
334bcc
.UNINDENT
334bcc
.INDENT 0.0
334bcc
.TP
334bcc
.B \-\-sslFIPSMode
334bcc
New in version 2.6.
334bcc
334bcc
.sp
334bcc
Directs the \fBmongoimport\fP to use the FIPS mode of the installed OpenSSL
334bcc
library. Your system must have a FIPS compliant OpenSSL library to use
334bcc
the \fI\-\-sslFIPSMode\fP option.
334bcc
.sp
334bcc
\fBNOTE:\fP
334bcc
.INDENT 7.0
334bcc
.INDENT 3.5
334bcc
FIPS Compatible SSL is
334bcc
available only in \fI\%MongoDB Enterprise\fP\&. See
334bcc
http://docs.mongodb.org/manual/tutorial/configure\-fips for more information.
334bcc
.UNINDENT
334bcc
.UNINDENT
334bcc
.UNINDENT
334bcc
.INDENT 0.0
334bcc
.TP
334bcc
.B \-\-username <username>, \-u <username>
334bcc
Specifies a username with which to authenticate to a MongoDB database
334bcc
that uses authentication. Use in conjunction with the \fB\-\-password\fP and
334bcc
\fB\-\-authenticationDatabase\fP options.
334bcc
.UNINDENT
334bcc
.INDENT 0.0
334bcc
.TP
334bcc
.B \-\-password <password>, \-p <password>
334bcc
Specifies a password with which to authenticate to a MongoDB database
334bcc
that uses authentication. Use in conjunction with the \fB\-\-username\fP and
334bcc
\fB\-\-authenticationDatabase\fP options.
334bcc
.sp
334bcc
If you do not specify an argument for \fI\-\-password\fP, \fBmongoimport\fP will
334bcc
prompt interactively for a password on the console.
334bcc
.UNINDENT
334bcc
.INDENT 0.0
334bcc
.TP
334bcc
.B \-\-authenticationDatabase <dbname>
334bcc
New in version 2.4.
334bcc
334bcc
.sp
334bcc
Specifies the database that holds the user\(aqs credentials.
334bcc
.UNINDENT
334bcc
.INDENT 0.0
334bcc
.TP
334bcc
.B \-\-authenticationMechanism <name>
334bcc
\fIDefault\fP: MONGODB\-CR
334bcc
.sp
334bcc
New in version 2.4.
334bcc
334bcc
.sp
334bcc
Changed in version 2.6: Added support for the \fBPLAIN\fP and \fBMONGODB\-X509\fP authentication
334bcc
mechanisms.
334bcc
334bcc
.sp
334bcc
Specifies the authentication mechanism the \fBmongoimport\fP instance uses to
334bcc
authenticate to the \fBmongod\fP or \fBmongos\fP\&.
334bcc
.TS
334bcc
center;
334bcc
|l|l|.
334bcc
_
334bcc
T{
334bcc
Value
334bcc
T}	T{
334bcc
Description
334bcc
T}
334bcc
_
334bcc
T{
334bcc
MONGODB\-CR
334bcc
T}	T{
334bcc
MongoDB challenge/response authentication.
334bcc
T}
334bcc
_
334bcc
T{
334bcc
MONGODB\-X509
334bcc
T}	T{
334bcc
MongoDB SSL certificate authentication.
334bcc
T}
334bcc
_
334bcc
T{
334bcc
PLAIN
334bcc
T}	T{
334bcc
External authentication using LDAP. You can also use \fBPLAIN\fP
334bcc
for authenticating in\-database users. \fBPLAIN\fP transmits
334bcc
passwords in plain text. This mechanism is available only in
334bcc
\fI\%MongoDB Enterprise\fP\&.
334bcc
T}
334bcc
_
334bcc
T{
334bcc
GSSAPI
334bcc
T}	T{
334bcc
External authentication using Kerberos. This mechanism is
334bcc
available only in \fI\%MongoDB Enterprise\fP\&.
334bcc
T}
334bcc
_
334bcc
.TE
334bcc
.UNINDENT
334bcc
.INDENT 0.0
334bcc
.TP
334bcc
.B \-\-gssapiServiceName
334bcc
New in version 2.6.
334bcc
334bcc
.sp
334bcc
Specify the name of the service using \fBGSSAPI/Kerberos\fP\&. Only required if the service does not use the
334bcc
default name of \fBmongodb\fP\&.
334bcc
.sp
334bcc
This option is available only in MongoDB Enterprise.
334bcc
.UNINDENT
334bcc
.INDENT 0.0
334bcc
.TP
334bcc
.B \-\-gssapiHostName
334bcc
New in version 2.6.
334bcc
334bcc
.sp
334bcc
Specify the hostname of a service using \fBGSSAPI/Kerberos\fP\&. \fIOnly\fP required if the hostname of a machine does
334bcc
not match the hostname resolved by DNS.
334bcc
.sp
334bcc
This option is available only in MongoDB Enterprise.
334bcc
.UNINDENT
334bcc
.INDENT 0.0
334bcc
.TP
334bcc
.B \-\-db <database>, \-d <database>
334bcc
Specifies the name of the database on which to run the \fBmongoimport\fP\&.
334bcc
.UNINDENT
334bcc
.INDENT 0.0
334bcc
.TP
334bcc
.B \-\-collection <collection>, \-c <collection>
334bcc
Specifies the collection to import.
334bcc
.sp
334bcc
New in version 2.6: If you do not specify \fI\-\-collection\fP,
334bcc
\fBmongoimport\fP takes the collection name from the input
334bcc
filename. MongoDB omits the extension of the file from the
334bcc
collection name, if the input file has an extension.
334bcc
334bcc
.UNINDENT
334bcc
.INDENT 0.0
334bcc
.TP
334bcc
.B \-\-fields <field1[,field2]>, \-f <field1[,field2]>
334bcc
Specify a comma separated list of field names when importing \fIcsv\fP
334bcc
or \fItsv\fP files that do not have field names in the first (i.e.
334bcc
header) line of the file.
334bcc
.sp
334bcc
If you attempt to include \fI\%\-\-fields\fP when importing JSON data,
334bcc
\fBmongoimport\fP will return an error. \fI\%\-\-fields\fP is only for \fIcsv\fP
334bcc
or \fItsv\fP imports.
334bcc
.UNINDENT
334bcc
.INDENT 0.0
334bcc
.TP
334bcc
.B \-\-fieldFile <filename>
334bcc
As an alternative to \fI\%\-\-fields\fP, the \fI\%\-\-fieldFile\fP
334bcc
option allows you to specify a file that holds a list of field names if
334bcc
your \fIcsv\fP or \fItsv\fP file does not include field names in the
334bcc
first line of the file (i.e. header). Place one field per line.
334bcc
.sp
334bcc
If you attempt to include \fI\%\-\-fieldFile\fP when importing JSON data,
334bcc
\fBmongoimport\fP will return an error. \fI\%\-\-fieldFile\fP is only for \fIcsv\fP
334bcc
or \fItsv\fP imports.
334bcc
.UNINDENT
334bcc
.INDENT 0.0
334bcc
.TP
334bcc
.B \-\-ignoreBlanks
334bcc
Ignores empty fields in \fIcsv\fP and \fItsv\fP exports. If not
334bcc
specified, \fBmongoimport\fP creates fields without values in
334bcc
imported documents.
334bcc
.sp
334bcc
If you attempt to include \fI\%\-\-ignoreBlanks\fP when importing JSON data,
334bcc
\fBmongoimport\fP will return an error. \fI\%\-\-ignoreBlanks\fP is only for \fIcsv\fP
334bcc
or \fItsv\fP imports.
334bcc
.UNINDENT
334bcc
.INDENT 0.0
334bcc
.TP
334bcc
.B \-\-type <json|csv|tsv>
334bcc
Specifies the file type to import. The default format is \fIJSON\fP,
334bcc
but it\(aqs possible to import \fIcsv\fP and \fItsv\fP files.
334bcc
.sp
334bcc
The \fBcsv\fP parser accepts that data that complies with RFC
334bcc
\fI\%RFC 4180\fP\&. As a result, backslashes are \fInot\fP a valid escape
334bcc
character. If you use double\-quotes to enclose fields in the CSV
334bcc
data, you must escape internal double\-quote marks by prepending
334bcc
another double\-quote.
334bcc
.UNINDENT
334bcc
.INDENT 0.0
334bcc
.TP
334bcc
.B \-\-file <filename>
334bcc
Specifies the location and name of a file containing the data to import.
334bcc
If you do not specify a file, \fBmongoimport\fP reads data from
334bcc
standard input (e.g. "stdin").
334bcc
.UNINDENT
334bcc
.INDENT 0.0
334bcc
.TP
334bcc
.B \-\-drop
334bcc
Modifies the import process so that the target instance drops
334bcc
the collection before importing the data from the input.
334bcc
.UNINDENT
334bcc
.INDENT 0.0
334bcc
.TP
334bcc
.B \-\-headerline
334bcc
If using \fI\-\-type csv\fP or \fI\-\-type
334bcc
tsv\fP, uses the first line as field names.
334bcc
Otherwise, \fBmongoimport\fP will import the first line as a
334bcc
distinct document.
334bcc
.sp
334bcc
If you attempt to include \fI\%\-\-headerline\fP when importing JSON data,
334bcc
\fBmongoimport\fP will return an error. \fI\%\-\-headerline\fP is only for \fIcsv\fP
334bcc
or \fItsv\fP imports.
334bcc
.UNINDENT
334bcc
.INDENT 0.0
334bcc
.TP
334bcc
.B \-\-upsert
334bcc
Modifies the import process to update existing objects in the
334bcc
database if they match an imported object, while inserting all
334bcc
other objects.
334bcc
.sp
334bcc
If you do not specify a field or fields using the
334bcc
\fI\%\-\-upsertFields\fP \fBmongoimport\fP will upsert on the
334bcc
basis of the \fB_id\fP field.
334bcc
.INDENT 7.0
334bcc
.TP
334bcc
.B \&..versionchanged:: 3.0.0
334bcc
\fI\%\-\-upsert\fP is no longer needed when specifying upserts. Use
334bcc
\fI\%\-\-upsertFields\fP, which produces the same behavior.
334bcc
.UNINDENT
334bcc
.UNINDENT
334bcc
.INDENT 0.0
334bcc
.TP
334bcc
.B \-\-upsertFields <field1[,field2]>
334bcc
Specifies a list of fields for the query portion of the
334bcc
\fIupsert\fP\&. Use this option if the \fB_id\fP fields in the
334bcc
existing documents don\(aqt match the field in the document, but
334bcc
another field or field combination can uniquely identify
334bcc
documents as a basis for performing upsert operations.
334bcc
.INDENT 7.0
334bcc
.TP
334bcc
.B \&..versionchanged:: 3.0.0
334bcc
Modifies the import process to update existing objects in the
334bcc
database if they match based on the specified fields, while
334bcc
inserting all other objects.
334bcc
.sp
334bcc
If you do not specify a field, \fI\%\-\-upsertFields\fP will upsert on the basis of
334bcc
the \fB_id\fP field.
334bcc
.UNINDENT
334bcc
.sp
334bcc
To ensure adequate performance, indexes should exist for this
334bcc
field or fields.
334bcc
.UNINDENT
334bcc
.INDENT 0.0
334bcc
.TP
334bcc
.B \-\-stopOnError
334bcc
New in version 2.2.
334bcc
334bcc
.sp
334bcc
Forces \fBmongoimport\fP to halt the import operation at the
334bcc
first error rather than continuing the operation despite errors.
334bcc
.sp
334bcc
Changed in version 3.0.0: \fI\%\-\-stopOnError\fP interrupts the import operation when \fBmongoimport\fP encounters
334bcc
an insert or upsert error. Other error types will not stop
334bcc
the import.
334bcc
334bcc
.UNINDENT
334bcc
.INDENT 0.0
334bcc
.TP
334bcc
.B \-\-jsonArray
334bcc
Accepts the import of data expressed with multiple MongoDB documents
334bcc
within a single \fIJSON\fP array. Limited to
334bcc
imports of 16 MB or smaller.
334bcc
.sp
334bcc
Use \fI\%\-\-jsonArray\fP in conjunction with \fImongoexport \-\-jsonArray\fP\&.
334bcc
.UNINDENT
334bcc
.INDENT 0.0
334bcc
.TP
334bcc
.B \-\-maintainInsertionOrder
334bcc
\fIDefault\fP: False
334bcc
.sp
334bcc
If specified, \fBmongoimport\fP inserts the documents in the order of
334bcc
their appearance in the input source, otherwise \fBmongoimport\fP may
334bcc
perform the insertions in an arbitrary order.
334bcc
.UNINDENT
334bcc
.INDENT 0.0
334bcc
.TP
334bcc
.B \-\-writeConcern <document>
334bcc
\fIDefault\fP: majority
334bcc
.sp
334bcc
Specifies the \fIwrite concern\fP for each write operation that \fBmongoimport\fP
334bcc
writes to the target database.
334bcc
.sp
334bcc
Specify the write concern as a document with \fIw options\fP\&.
334bcc
.UNINDENT
334bcc
.SH USE
334bcc
.sp
334bcc
In this example, \fBmongoimport\fP imports the \fIcsv\fP
334bcc
formatted data in the \fB/opt/backups/contacts.csv\fP into the
334bcc
collection \fBcontacts\fP in the \fBusers\fP database on the MongoDB
334bcc
instance running on the localhost port numbered
334bcc
\fB27017\fP\&. \fBmongoimport\fP determines the name of files using
334bcc
the first line in the CSV file, because of the \fI\-\-headerline\fP:
334bcc
.INDENT 0.0
334bcc
.INDENT 3.5
334bcc
.sp
334bcc
.nf
334bcc
.ft C
334bcc
mongoimport \-\-db users \-\-collection contacts \-\-type csv \-\-headerline \-\-file /opt/backups/contacts.csv
334bcc
.ft P
334bcc
.fi
334bcc
.UNINDENT
334bcc
.UNINDENT
334bcc
.sp
334bcc
Since \fBmongoimport\fP uses the input file name, without the
334bcc
extension, as the collection name if \fB\-c\fP or \fB\-\-collection\fP is
334bcc
unspecified. The following example is equivalent:
334bcc
.INDENT 0.0
334bcc
.INDENT 3.5
334bcc
.sp
334bcc
.nf
334bcc
.ft C
334bcc
mongoimport \-\-db users \-\-type csv \-\-headerline \-\-file /opt/backups/contacts.csv
334bcc
.ft P
334bcc
.fi
334bcc
.UNINDENT
334bcc
.UNINDENT
334bcc
.sp
334bcc
In the following example, \fBmongoimport\fP imports the data in
334bcc
the \fIJSON\fP formatted file \fBcontacts.json\fP into the collection
334bcc
\fBcontacts\fP on the MongoDB instance running on the localhost port
334bcc
number 27017.
334bcc
.INDENT 0.0
334bcc
.INDENT 3.5
334bcc
.sp
334bcc
.nf
334bcc
.ft C
334bcc
mongoimport \-\-db users \-\-collection contacts \-\-file contacts.json
334bcc
.ft P
334bcc
.fi
334bcc
.UNINDENT
334bcc
.UNINDENT
334bcc
.sp
334bcc
In the next example, \fBmongoimport\fP imports data from the
334bcc
file \fB/opt/backups/mdb1\-examplenet.json\fP into the collection
334bcc
\fBcontacts\fP within the database \fBmarketing\fP on a remote MongoDB
334bcc
database. This \fBmongoimport\fP accesses the \fBmongod\fP
334bcc
instance running on the host \fBmongodb1.example.net\fP over port
334bcc
\fB37017\fP, which requires the username \fBuser\fP and the password
334bcc
\fBpass\fP\&.
334bcc
.INDENT 0.0
334bcc
.INDENT 3.5
334bcc
.sp
334bcc
.nf
334bcc
.ft C
334bcc
mongoimport \-\-host mongodb1.example.net \-\-port 37017 \-\-username user \-\-password pass \-\-collection contacts \-\-db marketing \-\-file /opt/backups/mdb1\-examplenet.json
334bcc
.ft P
334bcc
.fi
334bcc
.UNINDENT
334bcc
.UNINDENT
334bcc
.SH TYPE FIDELITY
334bcc
.sp
334bcc
\fBWARNING:\fP
334bcc
.INDENT 0.0
334bcc
.INDENT 3.5
334bcc
\fBmongoimport\fP and \fBmongoexport\fP do not reliably
334bcc
preserve all rich \fIBSON\fP data types because \fIJSON\fP can
334bcc
only represent a subset of the types supported by BSON. As a result,
334bcc
data exported or imported with these tools may lose some measure of
334bcc
fidelity. See the \fBExtended JSON\fP
334bcc
reference for more information.
334bcc
.UNINDENT
334bcc
.UNINDENT
334bcc
.sp
334bcc
JSON can only represent a subset of the types supported by BSON. To
334bcc
preserve type information, \fBmongoimport\fP accepts \fBstrict
334bcc
mode representation\fP for certain
334bcc
types.
334bcc
.sp
334bcc
For example, to preserve type information for BSON types
334bcc
\fBdata_date\fP and \fBdata_numberlong\fP during
334bcc
\fBmongoimport\fP, the data should be in strict mode
334bcc
representation, as in the following:
334bcc
.INDENT 0.0
334bcc
.INDENT 3.5
334bcc
.sp
334bcc
.nf
334bcc
.ft C
334bcc
{ "_id" : 1, "volume" : { "$numberLong" : "2980000" }, "date" : { "$date" : "2014\-03\-13T13:47:42.483\-0400" } }
334bcc
.ft P
334bcc
.fi
334bcc
.UNINDENT
334bcc
.UNINDENT
334bcc
.sp
334bcc
For the \fBdata_numberlong\fP type, \fBmongoimport\fP
334bcc
converts into a float during the import.
334bcc
.sp
334bcc
See http://docs.mongodb.org/manual/reference/mongodb\-extended\-json for a complete list of
334bcc
these types and the representations used.
334bcc
.SH AUTHOR
334bcc
MongoDB Documentation Project
334bcc
.SH COPYRIGHT
334bcc
2011-2015
334bcc
.\" Generated by docutils manpage writer.
334bcc
.