Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-2652

Suggestion for /manual/reference/operator/query/exists/



    • Type: Improvement
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: v1.3.1
    • Component/s: manual
    • Labels:
    • # Replies:
    • Last comment by Customer:
    • Actual Time:


      $exists selects the documents that contain the field if <boolean> is true. If <boolean> is false, the query only returns the documents that do not contain the field. $exists does match documents that contain the field that stores the null value.

      When you specify true to the $exists operator, the query will select documents where the value of the specified field is null. If you specify false to $exists, the query will not match fields that hold the null value.

      The second paragraph seems redundant and the second sentence is particularly confusing since we're dealing with a double negative (false value and "not match").

      The boolean argument for $exists only determines whether the field, irrespective of its value, should exist in the document. Maybe adding that in the first paragraph will increase readability:

      If <boolean> is true, $exists matches the documents that contain the field. If <boolean> is false, the query only returns the documents that do not contain the field. $exists only considers whether a field is present in the document, irrespective of its value (e.g. { $exists: true } would match a field with a null value).

      Here, I think it's also more consistent to refer to query operators "matching" documents rather than "selecting" them. A document is ultimately selected for the result set when a logical combination of its query operators match (after any and/or logic).




            • Votes:
              0 Vote for this issue
              3 Start watching this issue


              • Created:
                Days since reply:
                6 years, 5 days ago
                Date of 1st Reply: