[DOCS-6438] Comment on: "manual/reference/operator/aggregation/anyElementTrue.txt" Created: 23/Oct/15  Updated: 03/Nov/17  Resolved: 23/Oct/15

Status: Closed
Project: Documentation
Component/s: None
Affects Version/s: None
Fix Version/s: 01112017-cleanup

Type: Bug Priority: Major - P3
Reporter: Docs Collector User (Inactive) Assignee: Kay Kim (Inactive)
Resolution: Done Votes: 0
Labels: collector-298ba4e7
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Location: https://docs.mongodb.org/manual/reference/operator/aggregation/anyElementTrue/
User-Agent: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0
Referrer: https://docs.mongodb.org/manual/reference/operator/aggregation/setIsSubset/
Screen Resolution: 1366 x 768
repo: docs
source: reference/operator/aggregation/anyElementTrue


Participants:
Days since reply: 8 years, 16 weeks, 5 days ago

 Description   

I can't understand the explanation. In the page at top level

{"$anyElementTrue:[[]]}

is provided as false. Using the document example its given as true. So which one is correct?



 Comments   
Comment by Kay Kim (Inactive) [ 23/Oct/15 ]

Emailed reporter explaining the difference:

{ $anyElementTrue: [ [ ] ] }

the <expression> being evaluated is [ ] i.e. does this expression have any element true? as an empty element it does not. hence the false.

vs.
having a document

{ "_id" : 6, "responses" : [ [ ] ] }

and the project pipeline:

 { $project: { responses: 1, isAnyTrue: { $anyElementTrue: [ "$responses" ] }, _id: 0 } }

the <expression> being evaluated is [ [ ] ] i.e. does this array have any element true? the array contains one element, an array (which happens to be an empty array), but an element nonetheless.

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