@@ -14,14 +14,14 @@ Query for Null or Missing Fields
1414 :backlinks: none
1515 :depth: 1
1616
17- ----------
17+ You can query for ``null`` or missing fields in MongoDB
18+ using the following methods:
1819
19- .. |arrow| unicode :: U+27A4
20+ .. |atlas-ref| replace :: :ref:`query-null-documents-atlas-ui`
2021
21- |arrow| Use the **Select your language** drop-down menu in the
22- upper-right to set the language of the following examples.
22+ .. include:: /includes/fact-methods.rst
2323
24- ----------
24+ .. include:: /includes/language-selector-instructions.rst
2525
2626.. tabs-selector:: drivers
2727
@@ -370,3 +370,68 @@ The query only returns the document that does *not* contain the
370370.. [#type0]
371371
372372 .. include:: /includes/extracts/4.2-changes-type-0.rst
373+
374+ .. _query-null-documents-atlas-ui:
375+
376+ Query for Null or Missing Fields with {+atlas+}
377+ ----------------------------------------------------
378+
379+ The example in this section uses the :atlas:`sample training dataset
380+ </sample-data/sample-training/>`. To learn how to load the sample dataset
381+ into your {+atlas+} deployment, see :atlas:`Load Sample Data
382+ </sample-data/#std-label-load-sample-data>`.
383+
384+ To query for a ``null`` or missing field in {+atlas+}, follow these steps:
385+
386+ .. procedure::
387+ :style: normal
388+
389+ .. step:: Navigate to the collection.
390+
391+ a. In the :atlas:`Atlas UI </atlas-ui/>`, click :guilabel:`Database` in the sidebar.
392+ #. For the database deployment that contains the sample data, click :guilabel:`Browse Collections`.
393+ #. In the left navigation pane, select the ``sample_training`` database.
394+ #. Select the ``companies`` collection.
395+
396+ .. step:: Insert a blank document.
397+
398+ Click the :guilabel:`Insert Document` button to display the
399+ dialog box, and then click :guilabel:`Insert`
400+ to insert a document with only the ``_id`` field.
401+
402+ .. step:: Specify a query filter document.
403+
404+ To find a document that contains a ``null`` or missing value,
405+ specify a :ref:`query filter document <document-query-filter>`
406+ in the :guilabel:`Filter` field. A query filter document uses
407+ :ref:`query operators <csfle-supported-query-operators>`
408+ to specify search conditions.
409+
410+ Different query operators in MongoDB treat ``null`` values differently.
411+ To apply a query filter, copying each of the following documents into the
412+ :guilabel:`Filter` search bar and click :guilabel:`Apply`.
413+
414+ Use the following query filter to match documents that either contain a
415+ ``description`` field with a ``null`` value or do not contain the
416+ ``description`` field:
417+
418+ .. code-block:: javascript
419+
420+ { description : null }
421+
422+ Use the following query filter to match only documents that contain
423+ a ``description`` field with a ``null`` value. This filter specifies
424+ that the value of the field must be :ref:`BSON Type <bson-types>` ``Null``
425+ (BSON Type 10):
426+
427+ .. code-block:: javascript
428+
429+ { description : { $type: 10 } }
430+
431+ Use the following query filter to match only documents that
432+ do not contain the ``description`` field. Only the document
433+ that you inserted earlier should appear:
434+
435+ .. code-block:: javascript
436+
437+ { description : { $exists: false } }
0 commit comments