Search returns all comments for post with matching title
To reproduce:
- Create post with title "example"
- Create a couple of comments in this post
- Search for "example"
Result: Every single comment for this post appears in search results. Happens whether or not "post title only" is checked.
Does this happen when the searchtype is comments too?
Yes. And to be clear this is a problem on the main branch.
The above PR somewhat fixes it (for title_only searches), but really the issue is that when you're looking for posts only, we should be filtering by the post search type. Because currently how the search joins work, is that children of found items will be returned.
I'm starting to think that maybe the best solution is to just remove the join conditions that return children. I'm not sure the use case for it anyway.
Figured it out. The child joins were necessary, because otherwise you don't know whether a comment is in an nsfw community (and a lot similar cases).
All I had to do was add a content type filter to each search term filter.