Text and Subfield Search

The total movies count for genre either Mystery or Thriller is 7259 but in test case its being evaluated to 7261 . Do we need to correct the test case value ? Below is the test case .

test(“Can perform a genre search with multiple genres”, async () => {
const filters = { genre: [“Mystery”, “Thriller”] }
const { moviesList, totalNumMovies } = await MoviesDAO.getMovies({
filters,
})
expect(moviesList.length).toEqual(20)
expect(totalNumMovies).toEqual(7261)
const firstMovie = moviesList[0]
expect(firstMovie[“title”]).toEqual(“2 Fast 2 Furious”)
})

It is true, verifying the number of elements gives me the same result.
I also went with the Ticket: Projection, the total of movies was 2788, not the value that comes by default.
I’ve done.

@Anupam_83108, You never never change the case values. The test case values are chosen so that they verify that your modified code is correct. You have to fix your code, not the test cases. If the test case fails, your code is wrong or your configuration is wrong.

I used the same filter and and project values from home and it gives me the the correct record count 7259. Now my test case is through but the status page doesn’t display the code .

The most probable cause is they do something on the status page that

  1. your code does not handle some type input correctly AND
  2. the test case does not test for this type of input

I am stuck with this problem and couldn’t find the cause . Text and sub field search , test case passed . But the status page will not display the code.

I checked the Json response to verify the format and this is what I am getting
image

Not sure where else to check .

well…I’m having exactly the same issue… :roll_eyes:

I have spent 12 hrs in last 3 days to debug but couldnt find anything . I guess the admin needs to check on this . How do you tag admin to the post ?

Anupam

I just make it work, mi issue was that I was ussing the “genre” param directly inside my query instead of using the variable “searchGenre”…,that fixed the issue, besides of that, with both cases all the tests passed…(silly issue hehe)…

5 Likes

I am already using ‘searchGenre’ parameter .

  1. Get the genre
  2. check if its array or not
  3. Convert to array
  4. Assigne the array to searchGenre variable
  5. pass the variable to find method

As @matisimone, mentioned searchGenre as to be used because sometime we receive a string not an array of string. In my opinion this case should be tested in the unit tests too.

const searchGenre = Array.isArray(genre) ? genre : genre.split(’,’)
what else am i missing ?

why don’t try to restart the app? also open it in a new tab/window…I don’t know what else could it be…

I don’t think you have to change the way searchGenre is assigned.

Not many things can go wrong.

  1. query does not use the correct key
  2. query does not use the correct array operator
  3. query does not use the correct value for the array operator
  4. project is not projecting correctly

This is the xhr req/response when i run the status page. All the reques status code 200 and green . So where is the issue.
Hopefully moderators can help .

  1. what key are you using for the query
  2. what array operator are you using
  3. what is the value you pass to the array operator
  4. what is your projection
  5. (I forgot that before) what is your sort

const searchGenre = Array.isArray(genre) ? genre : genre.split(’,’)
const query = {genres:{$in:searchGenre}}
const project = {title:1,year:1,runtime:1,cast:1,poster:1,plot:1,fullplot:1,lastupdated:1,type:1,directors:1,imdb:1,countries:1,rated:1,genres:1}
const sort = DEFAULT_SORT

return { query, project, sort }

check my response below

Like I wrote before:

Why don’t you project the whole document with project = {}. I did not see anywhere that we have to project anything else than the whole document. By explicitly including fields, you may miss some fields that are need down the line.

project ={} worked. Thanks .

2 Likes