Book Image

ElasticSearch Blueprints

Book Image

ElasticSearch Blueprints

Overview of this book

Table of Contents (15 chapters)
Elasticsearch Blueprints
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

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.