Background:
I had a 2018 Air that I transferred to my new 2022 Air. Everything seemed fine, except that Spotlight would only search my entire Mac, and not the individual folder I wanted to search.
I tried the Terminal fix mentioned by mjvandecreek without any luck. In my case, it didn't work.
Solution:
So this is how I made it work, on both my Air and my wife's identical Air, with the same issue.
I went to System Settings > Siri & Spotlight > Spotlight Privacy. Hit the + symbol and added my entire HD and hit done and saved all preferences. As expected, I opened a random folder and tried a spotlight search and nothing came up - because I was blocking my entire hard drive.
I then repeated the steps above and removed my HD from the list and hit done and saved all preferences. I opened another random folder and tried a spotlight search again. This time both the HD and individual folders showed results. I was able to repeat this process with the same successful result on my wife's Air.
Conclusion:
I am only left to think that the indexing of our computer folders was corrupted - maybe from the transfer. When I blocked everything, it erased the index, and when I unblocked it, it re-indexed everything properly and began functioning again.
I don't know if this is a real fix, but it worked for me on two computers - so it was repeatable. I hope it works for others as well. Please reach out to me if it works for you also, so we can pass the word on to others.