Ticket Paging fails with Aggregation

I was able to pass the test case and ticket with this code

moviesCollection.find(castFilter).sort(sort).limit(limit).skip(skip).into(movies);

But if I try to use aggregation here with the following code

    Bson castFilter = Filters.in("genres", genres);
    // sort key
    Bson sort = Sorts.descending(sortKey);
    Bson limitBson = Aggregates.limit(limit);
    Bson skipBson = Aggregates.skip(skip);

    List<Bson> pipeline = new ArrayList<>();
    pipeline.add(castFilter);
    pipeline.add(sort);
    pipeline.add(limitBson);
    pipeline.add(skipBson);



    List<Document> movies = new ArrayList<>();
    moviesCollection.aggregate(pipeline).into(movies);

It fails with the exception Command failed with error 8000 (AtlasError): ‘genres is not allowed in this atlas tier’ on server

In aggregation, you will need to use $match stage to use filter. Here is the link which can be of help:

https://mongodb.github.io/mongo-java-driver/3.6/javadoc/?com/mongodb/client/model/Aggregates.html

Kanika

That helped. Thanks

1 Like