@Test
  void withLimit() throws Exception {
    // set of scroll sizes / limits to tests
    final int[] samples = {1, 2, 3, SIZE - 1, SIZE, SIZE + 1, 2 * SIZE, SIZE * SIZE};
    for (int scrollSize: samples) {
      for (int limit: samples) {
        ElasticModelRepository repository = new ElasticModelRepository(backend(scrollSize));
        final int expected = Math.min(SIZE, limit);

        // with limit
        CriteriaChecker.<ElasticModel>ofFetcher(repository.findAll().limit(limit))
                .toList(ElasticModel::string)
                .hasSize(expected);

        // sort expected results manually
        final List<String> expectedStrings = IntStream.range(0, SIZE)
                .mapToObj(i -> "s" + i)
                .sorted()
                .limit(expected)
                .collect(Collectors.toList());
        // add order by
        CriteriaChecker.<ElasticModel>ofFetcher(repository.findAll()
                .orderBy(ElasticModelCriteria.elasticModel.string.asc())
                        .limit(limit))
                .toList(ElasticModel::string)
                .isOf(expectedStrings);

        // TODO scrolls are not cleared
        // assertNoActiveScrolls();
      }
    }
  }
Set scroll sizes like {@code 1, 2, 3 ...} and validates number of returned records
criteria/elasticsearch/test/org/immutables/criteria/elasticsearch/ScrollingTest.java