Search feature only pulling the “name” key/value

Hi Basir,

I’m trying to test my search feature and it’s only rendering results for the key value “name” in my data.  For example, if I search “kendrick” it wont pull any results, but if I type the album name “damn”, it pulls. I tested this further by changing the key value “name” to “kendrick” and it works.  I’ll note that I adjusted the amazona app to be a vinyl ecommerce site so what you had as “brand” is my “artist”, and what is “categories” is “genre” for my site.  Everything other than this aspect works 100% so I know there’s no issues with how I adjusted my key names. I want to know how to make the search feature correctly query for “brand” (or “artist” in my case).

here is my code:

const { vinyl, countVinyl, genres, artists, pages } = props;
   const filterSearch = ({
  }) => {
    const { query } = router;
    if (page) query.page = page;
    if (searchQuery) query.searchQuery = searchQuery;
    if (sort) query.sort = sort;
    if (genre) query.genre = genre;
    if (artist) query.artist = artist;
    if (price) query.price = price;
    if (rating) query.rating = rating;
    if (min) query.min ? query.min : query.min === 0 ? 0 : min;
    if (max) query.max ? query.max : query.max === 0 ? 0 : max;
      pathname: router.pathname,
      query: query,
  const genreHandler = (e) => {
    filterSearch({ genre: e.target.value });
  const pageHandler = (page) => {
    filterSearch({ page });
  const artistHandler = (e) => {
    filterSearch({ artist: e.target.value });

await db.connect()
    const genres = await Vinyl.find().distinct('genre')
    const artists = await Vinyl.find().distinct('artist')
    const productDocs = await Vinyl.find(
    .skip(pageSize * (page - 1))
     const countVinyl = await Vinyl.countDocuments({
    await db.disconnect()
    const vinyl = productDocs.map(db.convertDocToObj)
     return {
        props: {
            pages: Math.ceil(countVinyl / pageSize),

      name: "DAMN",
      slug: "kendrick-lamar",
      genre: "Rap",
      image: "/images/damn1.png",
      price: 30,
      artist: "Kendrick Lamar",
      rating: 5.0,
      numReviews: 99,
      countInStock: 15,
        "DAMN is the fourth studio album by American rapper Kendrick Lamar. It was released on April 14, 2017, through Top Dawg Entertainment, Aftermath Entertainment and Interscope Records.",

Dominic Asked question May 11, 2023