You can use the parent-child in ES to achieve this:
- Define the parent (article) and child (comment)
- Index data. You should know how to index child data as it will difference from normal (need to specify parent in the index request)
- Use
has_child
query to query forarticle
that matched some fields incomment
I wrote a full working sample script for it: https://gist.github.com/dqduc/efa66047358dac66461b
You can run it to test and send me your feedback. I guess you're new to ES and parent-child relationship in ES.