Stuck at Faceted Search

Hi there,

Can someone please provide me a hint about how to get through this exercise?

I’ve tried adding this code within const queryPipeline = [ $match: {rating}, $group ]

However, for obvious reasons, it seems absurd and therefore, not working.

Can someone please help me out here?

I’ve already spend a good amount of hours trying to figure out the solution.

Thank you.

Why are you trying to implement $match again?, also why do we need $group here

Don’t we need to match based on the rating?

“As a user, I want to be able to filter cast search results by one facet, metacritic rating.”

we have to filter cast search result based on something, also if you read below statement again it may be helpful

–The method facetedSearch uses the Aggregation Framework, and the individual stages in the pipeline have already been completed. Follow instructions in themoviesDAO.js file to append the required stages to the pipeline object.

1 Like

To be a bit clearer on the confusing thread of discussion here.

The exercise in this case does not actually require you to edit or add any aggregation stages, as ALL the necessary code for those stages is included within the function facetedSearch().

Specifically, add the predefined pipeline stages to the existing “partial” pipeline in the correct order:

const queryPipeline = [
  matchStage,
  sortStage,
  // TODO Ticket: Faceted Search
  // Add the stages to queryPipeline in the correct order.
]

So the implementation already shows you the first two stages as are defined in constants at the top of the function definition, what your job here is to then decide which of the other defined pipeline stages need to be added here, and in the correct order.

HINT - There’s quite a lot of material on the internet at large about the correct order of two of the pipeline stages in particular, if not made immediately apparent from the official documentation

But no need to take my word for that instruction, since the full instruction is already contained within the code as well:

/**
Ticket: Faceted Search

Please append the skipStage, limitStage, and facetStage to the queryPipeline
(in that order). You can accomplish this by adding the stages directly to
the queryPipeline.

The queryPipeline is a Javascript array, so you can use push() or concat()
to complete this task, but you might have to do something about `const`.
*/

Nice! They are even prepared to outright tell you the three stage constants which you actually need to use. That’s pretty generous since there are only four to choose from and one should be pretty obvious that it’s not the one to use here.

So the only real advice here is that you probably DON’T want to push() or concat() here if the problem confused you already. Instead simply edit the array content and add the three additional items in the correct order.

SECOND HINT: As long as those are the only changes you make to the function ( and indeed the unit test, which you should know yo do NOT edit because you’ve been reading all the helpful comments on other threads here which already say that :wink: ), then all you need to is move the order of those three stages* around at the end of the existing pipeline and keep running the unit test until it passes.

Or spend a few minutes reviewing course material and documentation to find a pretty simple answer logically, then pat yourself on the back for learning something. Leaving the choice of which up to you.


N.B Careful readers may note that the course material itself this time decided to provide the direct answer for the question.

4 Likes

Got it.

That was literally too dumb of me.

Thanks for the help.

Hi ,

I am still stuck at this faceted search.My testcase are not apssing .

What did you try? What issues did you get?

Provide a screenshots of the problems you faced?

I have added stages to pipelines in correct order.

But getting issue, in one testcase

Please help, i am stuck.

Hi @Pallavi_Sinha,

Let me know if you are still facing any issue.

Kanika

the answer is obvious but thanks for relieving the mindblock on this

1 Like