Skip to content

Commit 83db7cd

Browse files
zach-carrjeff-allen-mongo
authored andcommitted
(DOCSP-8265-fix) Compass Import/Export improvements (#236)
* (DOCSP-8265) Update Compass import/export procedures * Updated from copy review * Add sampling note * Updates from copy review * Final copy review
1 parent b823c52 commit 83db7cd

12 files changed

+161
-78
lines changed
36.8 KB
Loading
41.3 KB
Loading
Loading
Loading
Loading
Loading
114 KB
Loading
-38.1 KB
Loading

source/import-export.txt

Lines changed: 25 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -49,32 +49,46 @@ that it is formatted correctly.
4949
name: JSON
5050
content: |
5151

52-
When importing data from a **JSON** file, each document must exist on
53-
its own line in the file. Do not use commas at the end of lines to
54-
separate documents.
52+
When importing data from a **JSON** file, you can format your
53+
data as:
54+
55+
- Newline-delimited documents, or
56+
57+
- Comma-separated documents in an array
5558

5659
.. example::
5760

58-
The following ``.json`` file imports three documents:
61+
The following newline-delimited ``.json`` file is formatted
62+
correctly:
5963

6064
.. code-block:: javascript
6165

6266
{ "type": "home", "number": "212-555-1234" }
6367
{ "type": "cell", "number": "646-555-4567" }
6468
{ "type": "office", "number": "202-555-0182"}
6569

66-
|compass| automatically generates :manual:`ObjectIDs
70+
The following comma-separated ``.json`` array file is also
71+
formatted correctly:
72+
73+
.. code-block:: javascript
74+
75+
[{ "type": "home", "number": "212-555-1234" }, { "type": "cell", "number": "646-555-4567" }, { "type": "office", "number": "202-555-0182"}]
76+
77+
|compass-short| ignores line breaks in JSON arrays.
78+
79+
|compass-short| automatically generates :manual:`ObjectIDs
6780
</reference/method/ObjectId/>` for these objects on import
6881
since no ObjectIDs were specified in the initial JSON.
6982

7083
- id: csv
7184
name: CSV
7285
content: |
7386

74-
When importing data from a **CSV** file, the first line of the file
75-
must be a comma-separated list of your document field names. Subsequent
76-
lines in the file must be comma-separated field values in the order
77-
corresponding with the field order in the first line.
87+
When importing data from a **CSV** file, the first line of the
88+
file must be a comma-separated list of your document field
89+
names. Subsequent lines in the file must be comma-separated
90+
field values in the order corresponding with the field order
91+
in the first line.
7892

7993
.. example::
8094

@@ -109,9 +123,8 @@ Export Data from a Collection
109123

110124
|compass| can export data from a collection as either a
111125
**JSON** or **CSV** file. If you specify a
112-
:ref:`filter <query-bar-filter>` in the
113-
:ref:`query bar <compass-query-bar>` prior to export, |compass-short|
114-
can optionally only export documents which match the specified query.
126+
:ref:`filter <query-bar-filter>`, |compass-short| only exports
127+
documents which match the specified query.
115128

116129
Behavior
117130
~~~~~~~~
@@ -136,20 +149,6 @@ Procedure
136149

137150
.. include:: /includes/fact-export-progress-bar.rst
138151

139-
Example
140-
```````
141-
142-
The following example exports the entire ``test.people``
143-
collection as a ``.json`` file called ``test-export.json``:
144-
145-
.. figure:: /images/compass/export-data-example.png
146-
:alt: Export data example
147-
:figwidth: 600px
148-
149-
The specified ``{ age: 24 }`` query is ignored and the entire
150-
collection is exported because the
151-
:guilabel:`Export Full Collection` toggle is enabled.
152-
153152
.. tab:: Export Filtered Subset of a Collection
154153
:tabid: export-filter
155154

@@ -158,15 +157,3 @@ Procedure
158157
.. include:: /includes/steps/export-filter.rst
159158

160159
.. include:: /includes/fact-export-progress-bar.rst
161-
162-
Example
163-
```````
164-
165-
The following example a filtered subset of the
166-
``test.flightStats`` collection as a CSV file called
167-
``cvg-msp.csv``. Only documents with an ``arrivalAirportFsCode``
168-
of either ``CVG`` or ``MSP`` are included in hte export.
169-
170-
.. figure:: /images/compass/export-data-filter-example.png
171-
:alt: Export data with filter example
172-
:figwidth: 600px

source/includes/steps-export-filter.yaml

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,78 @@
1-
title: Navigate to the :doc:`collection </collections>` you wish to export data from.
1+
title: Navigate to the :doc:`collection </collections>` you wish to
2+
export data from.
23
level: 4
34
ref: select-collection
45
content: |
56
You can either select the collection from the
67
:doc:`Collections </collections>` tab or click the collection in the
78
left-hand pane.
9+
810
---
911
title: "Specify a filter in the Query Bar"
1012
level: 4
1113
ref: export-specify-filter
1214
content: |
13-
Specify a :ref:`filter <query-bar-filter>` in the :ref:`query bar <compass-query-bar>` to export only the documents which match
14-
the filter.
15+
Specify a :ref:`filter <query-bar-filter>` in the
16+
:ref:`query bar <compass-query-bar>` to export only the documents
17+
which match the filter.
18+
1519
---
16-
title: Click :guilabel:`Collection` in the top-level menu and select :guilabel:`Export Collection`
20+
title: Click :guilabel:`Collection` in the top-level menu and select
21+
:guilabel:`Export Collection`
1722
level: 4
1823
ref: export-collection
1924
content: |
20-
21-
|
22-
2325
.. figure:: /images/compass/export-data-filter-option-select.png
2426
:alt: Export data select menu
2527
2628
|compass-short| displays the following dialog:
2729
2830
.. figure:: /images/compass/export-data-dialog-filter.png
2931
:alt: Export data dialog
30-
:figwidth: 600px
32+
:width: 70%
3133
3234
The top section of the export dialog displays the query
33-
entered in the query bar.
35+
entered in the query bar. If you did not specify a query in the query
36+
bar, you can specify a query here.
37+
3438
---
35-
title: Choose the appropriate file type.
39+
title: Select document fields to include in your exported file.
3640
level: 4
37-
ref: click-file-type
41+
ref: select-export-fields
3842
content: |
39-
Under :guilabel:`Select Output File Type`, select either JSON or CSV.
43+
Only fields that are checked are included in the exported file.
44+
45+
You can add document fields to include with the :guilabel:`Add Field`
46+
button if the field you want to include is not automatically detected.
47+
48+
.. figure:: /images/compass/export-data-dialog-2.png
49+
:alt: Export data dialog, step 2
50+
:width: 70%
51+
52+
.. note::
53+
54+
|compass-short| samples your collection to pre-populate a list of
55+
fields. Fields which only appear in a small percentage of
56+
documents may not be automatically detected.
57+
58+
For details on sampling, see the :ref:`FAQ <compass-faq-sampling>`.
59+
4060
---
41-
title: Under :guilabel:`Select File`, choose where to export the file.
61+
title: Choose the appropriate file type.
4262
level: 4
43-
ref: click-file-location
63+
ref: click-file-type
64+
content: |
65+
Under :guilabel:`Select Export File Type`, select either
66+
:guilabel:`JSON` or :guilabel:`CSV`. If you select :guilabel:`JSON`,
67+
your data is exported to the target file as a comma-separated
68+
array of JSON objects.
69+
70+
Then, under :guilabel:`Output`, choose where to export the file to.
71+
72+
.. figure:: /images/compass/export-data-dialog-3.png
73+
:alt: Export data dialog, step 3
74+
:width: 70%
75+
4476
---
4577
title: Click :guilabel:`Export`.
4678
level: 4

source/includes/steps-export.yaml

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
title: Navigate to the :doc:`collection </collections>` you wish to export data from.
1+
title: Navigate to the :doc:`collection </collections>` you wish to
2+
export data from.
23
level: 4
34
ref: select-collection
45
content: |
@@ -7,36 +8,59 @@ content: |
78
left-hand pane.
89
910
---
10-
title: Click :guilabel:`Collection` in the top-level menu and select :guilabel:`Export Collection`
11+
title: Click :guilabel:`Collection` in the top-level menu and select
12+
:guilabel:`Export Collection`.
1113
level: 4
1214
ref: export-collection
1315
content: |
14-
15-
|
16-
1716
.. figure:: /images/compass/export-data-option-select.png
1817
:alt: Export data select menu
1918
2019
|compass-short| displays the following dialog:
2120
22-
.. figure:: /images/compass/export-data-dialog.png
23-
:alt: Export data dialog
24-
:figwidth: 600px
21+
.. figure:: /images/compass/export-data-dialog-1.png
22+
:alt: Export data dialog, step 1
23+
:width: 70%
24+
25+
The export dialog initially displays the query entered in the query
26+
bar prior to export, if applicable. If no query was specified, this
27+
section displays a ``find`` operation with no parameters, which
28+
returns all documents in the collection.
29+
30+
To ignore the query filter and export your entire collection, select
31+
:guilabel:`Export Full Collection` and click
32+
:guilabel:`Select Fields`.
2533
26-
The top section of the export dialog displays the query entered in the
27-
query bar prior to export, if applicable. Use this query to filter
28-
which collection documents are exported. If no query was specified,
29-
this section displays ``undefined``.
3034
---
31-
title: Choose the appropriate file type.
35+
title: Select document fields to include in your exported file.
3236
level: 4
33-
ref: click-file-type
37+
ref: select-export-fields
3438
content: |
35-
Under :guilabel:`Select Output File Type`, select either JSON or CSV.
39+
Only fields that are checked are included in the exported file.
40+
41+
You can add document fields to include with the :guilabel:`Add Field`
42+
button if the field you want to include is not automatically detected.
43+
44+
.. figure:: /images/compass/export-data-dialog-2.png
45+
:alt: Export data dialog, step 2
46+
:width: 70%
47+
3648
---
37-
title: Under :guilabel:`Select File`, choose where to export the file.
49+
title: Choose a file type and export location.
3850
level: 4
39-
ref: click-file-location
51+
ref: click-file-type
52+
content: |
53+
Under :guilabel:`Select Export File Type`, select either
54+
:guilabel:`JSON` or :guilabel:`CSV`. If you select :guilabel:`JSON`,
55+
your data is exported to the target file as a comma-separated
56+
array.
57+
58+
Then, under :guilabel:`Output`, choose where to export the file to.
59+
60+
.. figure:: /images/compass/export-data-dialog-3.png
61+
:alt: Export data dialog, step 3
62+
:width: 70%
63+
4064
---
4165
title: Click :guilabel:`Export`.
4266
level: 4

source/includes/steps-import.yaml

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
title: Navigate to the :doc:`collection </collections>` you wish to import data into.
1+
title: Navigate to the :doc:`collection </collections>` you wish to
2+
import data into.
23
level: 4
34
ref: select-collection
45
content: |
@@ -7,7 +8,8 @@ content: |
78
left-hand pane.
89
910
---
10-
title: Click the :guilabel:`Add Data` dropdown and select :guilabel:`Import File`.
11+
title: Click the :guilabel:`Add Data` dropdown and select
12+
:guilabel:`Import File`.
1113
level: 4
1214
ref: import-data
1315
content: |
@@ -19,25 +21,63 @@ content: |
1921
2022
.. figure:: /images/compass/import-data-dialog.png
2123
:alt: Import data dialog
24+
:width: 70%
2225
2326
---
24-
title: Choose the appropriate file type of the source data file.
27+
title: Select the location of the source data file under
28+
:guilabel:`Select File`.
29+
level: 4
30+
ref: click-file-location
31+
content: ""
32+
33+
---
34+
title: Choose the appropriate file type.
2535
level: 4
2636
ref: choose-file-type
2737
content: |
28-
Under :guilabel:`Select Input File Type`, select either JSON or CSV.
38+
39+
Under :guilabel:`Select Input File Type`, select either
40+
:guilabel:`JSON` or :guilabel:`CSV`.
41+
42+
If you are importing a CSV file, you may specify fields to import and
43+
the types of those fields under :guilabel:`Specify Fields and Types`.
44+
The default data type for all fields is string.
45+
46+
.. figure:: /images/compass/import-csv-options.png
47+
:alt: Select fields to import from a CSV file
48+
:width: 70%
49+
50+
To exclude a field from a CSV file you are importing, uncheck the
51+
checkbox next to that field name. To select a type for a field, use
52+
the dropdown menu below that field name.
2953
3054
---
31-
title: Select the location of the source data file under :guilabel:`Select File`.
55+
title: Configure import options.
3256
level: 4
33-
ref: click-file-location
57+
ref: import-options
3458
content: |
35-
.. raw:: html
59+
Under :guilabel:`Options`, configure the import options for your use
60+
case.
61+
62+
If you are importing a CSV file, you may select how your data
63+
is delimited.
64+
65+
For both JSON and CSV file imports, you can toggle
66+
:guilabel:`Ignore empty strings` and :guilabel:`Stop on errors`:
67+
68+
- If checked, :guilabel:`Ignore empty strings` drops fields with
69+
empty string values from your imported documents. The document is
70+
still imported with all other fields.
71+
72+
- If checked, :guilabel:`Stop on errors` prevents any data from being
73+
imported in the event of an error. If unchecked, data is inserted
74+
until an error is encountered and successful inserts are not rolled
75+
back. The import operation will not continue after encountering an
76+
error in either case.
3677
37-
<br>
3878
---
3979
title: Click :guilabel:`Import`.
4080
level: 4
4181
ref: click-import
42-
82+
content: ""
4383
...

0 commit comments

Comments
 (0)