Aggregation Java Flashcards

1
Q

Which factory class should be used for building aggregation pipeline stages?

A

The Aggregates class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Which factory class can be used to sort data?

A

The Sorts class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Which factory class can be used to project data?

A

The Projections class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Code an example of the aggregation pipeline strucutre

A
collection.aggregate(List.of(Aggregates1, Aggregates2, ...))
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Code an example using the match stage with multiple field criteria

A
var matchStage = match(and(eq(field, value), eq(field2, value2)));
collection.aggregate(List.of(matchStage));
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Code an example using the group stage

A
var groupStage = group("$groupKey", Accumulators...));
collection.aggregate(List.of(groupStage));
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which class should you use to perform accumulator operations?

A

The Accumulators class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Code an example using an ascending sort and limit stage

A
var sortStage = sort(Sorts.ascending(field1, field2));
var limitStage = limit(number);
collection.aggregate(List.of(sortStage, limitStage));
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Code an example of using the project stage

A
var projectStage = project(Projections...);
document.aggregate(List.of(projectStage));
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Code an example using the out stage

A
var outStage = out("collectionName");
collection.aggregate(List.of(outStage));
How well did you know this?
1
Not at all
2
3
4
5
Perfectly