Parent/child queries


#1

Let's say I have a parent/child relationship, Blog posts (parent) and comments (child), posts contain the post text and comments contain comment text.

I want to offer search functionality that will return comments, but will consider and score based on the content of both the comment text and the parent post text eg with these documents (shown as nested to save space)

post:
  text: foo
  comments: [
    { date: today, text: "Great post" }
  ]

post:
  text: bar
  comments: [
    { date: today, text: "Great post, as was the earlier one about foo" }
  ]

If the term we're looking for is 'foo' both comments will be in the results.

I've seen has_child/has_parent queries and filters but they appear only to consider the fields of either the parent or the child, I want to consider both.

What kind of query can I use to achieve this without resorting to a nested relationship?


(system) #2