July 2015
Intermediate to advanced
192 pages
3h 38m
English
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.
Read now
Unlock full access