Searching answers based on a criteria of questions
Let's now try to find the parents by querying against the child docs, which is the reverse of what we did in the previous section. Take a look at this query:
curl -XPOST localhost:9200/posts/rating/_search?pretty=true -d '{ "query": { "filtered": { "query": {"match_all": {}}, "filter": { "and": [ {"term": {"accepted": yes}}, { "has_parent": { "type": "post", "query": { "term": {"question": " Queries vs. Filters "} } } } ] } } }, "sort": [ { "rating" : {"order" : "desc"} } ] }'
Here, we get all the ratings whose question contains the term Queries vs. Filters
in a descending order.