[DOCS-2652] Suggestion for /manual/reference/operator/query/exists/ Created: 03/Feb/14  Updated: 16/Mar/15  Resolved: 21/Feb/14

Status: Closed
Project: Documentation
Component/s: manual
Affects Version/s: None
Fix Version/s: v1.3.1

Type: Improvement Priority: Minor - P4
Reporter: Jeremy Mikola Assignee: Bob Grabar
Resolution: Done Votes: 0
Labels: audit-2014
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Participants:
Days since reply: 9 years, 51 weeks, 5 days ago

 Description   

$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).



 Comments   
Comment by Githook User [ 21/Feb/14 ]

Author:

{u'username': u'bgrabar', u'name': u'Bob Grabar', u'email': u'bob.grabar@10gen.com'}

Message: DOCS-2652 reword definition of exists operator

Signed-off-by: Sam Kleinman <samk@10gen.com>
Branch: master
https://github.com/mongodb/docs/commit/3f0da28b2cc073481ec8dea080a4b91139be4824

Comment by Githook User [ 21/Feb/14 ]

Author:

{u'username': u'bgrabar', u'name': u'Bob Grabar', u'email': u'bob.grabar@10gen.com'}

Message: DOCS-2652 reword definition of exists operator
Branch: v2.4
https://github.com/mongodb/docs/commit/ae3dd46ebe8a0f870ab0b9c5043bfb48e45f27d1

Generated at Thu Feb 08 07:43:56 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.