The MongoDB Aggregation Framework | Chapter 4 - Core Aggregation - Multidimensional Grouping Quiz Answer

The MongoDB Aggregation Framework  Chapter 4 - Core Aggregation - Multidimensional Grouping Quiz Answer


The MongoDB Aggregation Framework | Chapter 4 - Core Aggregation - Multidimensional Grouping 


In this article i am gone to share MongoDB-University Course: The MongoDB Aggregation Framework | Chapter 4 - Core Aggregation - Multidimensional Grouping Quiz Answer with you..




Facets: Single Facet Query

Which of the following aggregation pipelines are single facet queries?

[
  {"$match": { "$text": {"$search": "network"}}},
  {"$sortByCount": "$offices.city"},
]

[
  {"$unwind": "$offices"},
  {"$project": { "_id": "$name", "hq": "$offices.city"}},
  {"$sortByCount": "$hq"},
  {"$sort": {"_id":-1}},
  {"$limit": 100}
]

[
  {"$match": { "$text": {"$search": "network"}}},
  {"$unwind": "$offices"},
  {"$sort": {"_id":-1}}
]

Facets: Manual Buckets

Assuming that field1 is composed of double values, ranging between 0 and Infinity, and field2 is of type string, which of the following stages are correct?
  • {'$bucket': { 'groupBy': '$field1', 'boundaries': [ 0.4, Infinity ]}}
  • {'$bucket': { 'groupBy': '$field1', 'boundaries': [ "a", 3, 5.5 ]}}
  • {'$bucket': { 'groupBy': '$field2', 'boundaries': [ "a", "asdas", "z" ], 'default': 'Others'}}


Facets: Auto Buckets

Auto Bucketing will ...
  • adhere bucket boundaries to a numerical series set by the granularity option.
  • randomly distributed documents accross arbitrarily defined bucket boundaries.
  • given a number of buckets, try to distribute documents evenly accross buckets.
  • count only documents that contain the groupBy field defined in the documents.


Facets: Multiple Facets

Which of the following statement(s) apply to the $facet stage?
  • The $facet stage allows several sub-pipelines to be executed to produce multiple facets.
  • The $facet stage allows the application to generate several different facets with one single database request.
  • The output of the individual facetsub − pipelinescanbesharedusingtheexpression $FACET.$.
  • We can only use facets stages ($sortByCount, $bucket and $bucketAuto) as sub-pipelines of $facet stage.








Post a Comment

0 Comments