lemmy icon indicating copy to clipboard operation
lemmy copied to clipboard

Search returns all comments for post with matching title

Open Nutomic opened this issue 2 months ago • 2 comments

To reproduce:

  1. Create post with title "example"
  2. Create a couple of comments in this post
  3. Search for "example"

Result: Every single comment for this post appears in search results. Happens whether or not "post title only" is checked.

Nutomic avatar Nov 14 '25 14:11 Nutomic

Does this happen when the searchtype is comments too?

dessalines avatar Nov 14 '25 16:11 dessalines

Yes. And to be clear this is a problem on the main branch.

Nutomic avatar Nov 17 '25 09:11 Nutomic

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.

dessalines avatar Dec 11 '25 20:12 dessalines

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.

dessalines avatar Dec 12 '25 02:12 dessalines

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.

dessalines avatar Dec 13 '25 06:12 dessalines