M220J Paging Ticket

I’ve a problem with M220j Ticket: Paging.

I can’t pass the PagingTest.java

Here is the error:

org.junit.ComparisonFailure: Expected title field does match: Please check your getMoviesByGenre() movies sort order.
Expected :Only the Dead
Actual :Wolf Hall

Looking at the parameter passed to the method by the test, I have tried this filter on compass.

{
 filter: {
  genres: {
   $in: [
    'History'
   ]
  }
 },
 sort: {
  'tomatoes.viewer.numReviews': -1
 },
 skip: 980,
 limit: 20
}

The result shows as the first movie “Wolf Hall”, while the Expected “Only the Dead” is the third.

Here below, my java code.

    public List<Document> getMoviesByGenre(String sortKey, int limit, int skip, String... genres) {
        // query filter
        Bson castFilter = Filters.in("genres", genres);
        // sort key
        Bson sort = Sorts.descending(sortKey);
        List<Document> movies = new ArrayList<>();
        // TODO > Ticket: Paging - implement the necessary cursor methods to support simple
        // pagination like skip and limit in the code below



        moviesCollection.find(castFilter).sort(sort).limit(limit).skip(skip).iterator()
        .forEachRemaining(movies::add);
        return movies;
    }

Can you explain to me, what is wrong with it?

Thanks for the attention.

Hi Roberto,
Can you get the ticket? if you do, just carry on.
for more information about this issue check:

Just a report here that I met the same problem.

Hi @caspar_06973,
Welcome to the community!

do you get the same message?

Expected :Only the Dead
Actual :Wolf Hall

Yes,
I think the answer should be the make sure the sequence of order/skip/limit ,
but what ever I tried, all the same result.

can you get the ticket with a failing test?

Sorry I can not pass the PagingTest, so I cant get the validation code.

What do you mean by “get the ticket” ?

Hi everybody,
I have the same problem too on this ticket:

Expected :Only the Dead
Actual :Wolf Hall

Are there any updates on this issue in order to fix it?
Thanks.

Hi @Roberto_Olivieri, @Gabriele_Vinucci & @caspar_06973,

We welcome you all to the MongoDB Community.

Thanks for highlighting this…!!

I apologize for the late response.
We are looking into it, kindly allow us some time.
We will surely get back to you soon with an update.

Meanwhile, as @Imad_Bouteraa stated if you are getting the validation code for this ticket, just carry on for now.

We really appreciate your patience.
Good luck with the rest of the course.

Kind Regards,
Kushagra

I have the same problem:

org.junit.ComparisonFailure: Expected title field does match: Please check your getMoviesByGenre() movies sort order.
Expected :Only the Dead
Actual :Of Men and War

public List<Document> getMoviesByGenre(String sortKey, int limit, int skip, String... genres) {
    // query filter
    Bson castFilter = Filters.in("genres", genres);
    // sort key
    Bson sort = Sorts.descending(sortKey);
    List<Document> movies = new ArrayList<>();
    // TODO > Ticket: Paging - implement the necessary cursor methods to support simple
    // pagination like skip and limit in the code below
    moviesCollection.find(castFilter)
            .sort(sort)
            .skip(skip)
            .limit(limit)
            .iterator()
    .forEachRemaining(movies::add);

Hi @Felipe_Lino,

Please accept our apologies for any inconvenience caused. Just to let you know, the task has been assigned to the team. We expect it to be live soon. Moreover, I will make sure to fix this as soon as possible.

Thanks for your understanding.

Best regards,
Kushagra

Hello, MongoDB curriculum team!

I’ve got the same problem with this ticket. Has it been solved or am I doing something wrong?

Hi @Illia_Otlev,

Kindly allow me some time to crosscheck and get back to you.

Thanks for your patience.

Regards,
Kushagra

I can`t complete the course without this ticket, and it’s the only one left.
I hope you can help me with that)

Thank you! Have a nice day!

Hello @Illia_Otlev and welcome to the community
are you getting the same message?

Expected :Only the Dead
Actual :Wolf Hall

Hello, Imad! Thank you!

No. This is my stacktrace:

And this is my stages:
pipeline.add(matchStage);
pipeline.add(sortStage);
pipeline.add(skipStage);
pipeline.add(limitStage);
pipeline.add(facetStage);

Hello @Illia_Otlev, @Felipe_Lino
I checked the movie Of Men and War
and indeed the movie doesn’t have a tomatoes field,
Since Only the Dead also doesn’t have a tomatoes field, mongodb can’t consistently sort them by tomatoes.viewer.numReviews
Long story short, the team has to update the test cases and test on movies having tomatoes.viewer.numReviews

When I get some time (probably this night), I’ll work on a workaround solution

1 Like

I see. Thank you for the update!
If there is anything I can help you with, please let me know.

Then I will wait for the news.

See the following related thread.

1 Like