elasticsearch/elasticsearch — pull request #7685 by martijnvg (2014-09-11 08:06:29+00:00)
Title: Parent/child: has_child or other p/c query wrapped in a query filter may emit wrong results

If a `has_child`, `has_parent` or `top_children` is indirectly wrapped in a `query` filter (for example via a `bool` query) then the results are incorrect. This bug manifests in all places in the dsl where `query` filter can be used.

This PR lets the `query` filter use the `CustomQueryWrappingFilter` class if the query being wrapped in a `query` filter indirectly uses a p/c query. (the case when p/c query was directly being wrapped was already covered).

Also if a `query` filter is wrapping a p/c query (either directly or indirectly) any filter wrapping it if forcefully never cached. Caching this would also lead to wrong results, since the p/c queries can't be cached per segment, while regular filter can.