M220J Paging Ticket

I like this idea

The easiest way to guarantee sort consistency is to include the _id field in your sort query.

thank you for the hint @steevej

1 Like
    Arrays.asList(new Document("$match", 
    new Document("genres", "History")), 
    new Document("$sort", 
    new Document("tomatoes.viewer.numReviews", -1L)), 
    new Document("$skip", 980L), 
    new Document("$limit", 20L))

Same issue - but i am getting Korengal both from the spring test as well as from the compass

If it is the same issue you should try the same solution.

1 Like

I can confirm that it works, if you add the “_id”-field in ascending order to your sorting.

I had some issues figuring out how to pass an ascending and descending BSON into the sort() function. You can make a list of BSON objects (I called it sorts), some of them “Sorts.ascending()”, some of them “Sorts.descending()” and then use “sort(Sorts.oderBy(sorts))” to add them to your query.