How to query/rank documents with individual matches and a shared key/parent

Hi!

I am trying to figure out how to solve a particular use case. I have blog posts and comments. I want to be able to find blog posts that have text matches ACROSS comments. e.g. if I search for "pizza, beer", I want to see blog posts where both "pizza" and "beer" occur across individual comments (i.e. one says pizza, another beer).

Right now I only have comments indexed. The index includes the blog post foreign key. I don't care about the blog post content, which is why I haven't indexed them. I only care about the comments.

So is there a way to say, search across comments, find the ones that match ANY of the given search terms (pizza OR beer), then somehow increase their score if there are other results with the same blog_post_id? I am happy with individual comment records being the search result, as opposed to blog posts. I just want them to rise to the top.

Or do I need to index blog posts, and either store a composite of all comment content in a single field on that index, join on comments? Or something else I haven't thought of?

Thanks!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.