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.

Get Elasticsearch Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.