@Test
  void distinct1() {
    ImmutableQuery query = Query.of(Person.class)
            .addProjections(Matchers.toExpression(person.nickName))
            .withDistinct(true);

    assertAgg(query, "{$project: {expr0: '$nickName'}}",
            "{$group: {_id: '$expr0'}}",
            "{$project: {expr0: '$_id'}}");

    assertAgg(query.withLimit(1), "{$project: {expr0: '$nickName'}}",
            "{$group: {_id: '$expr0'}}",
            "{$project: {expr0: '$_id'}}",
            "{$limit: 1}"
            );

    assertAgg(query.withLimit(1).withCount(true), "{$project: {expr0: '$nickName'}}",
            "{$group: {_id: '$expr0'}}",
            "{$project: {expr0: '$_id'}}",
            "{$limit: 1}",
            "{$count: 'count'}"
            );
  }
Testing single field: {@code select distinct nickName from ...}
criteria/mongo/test/org/immutables/criteria/mongo/AggregationQueryTest.java