WARNING: Version 0.90 of Elasticsearch has passed its EOL date.
This documentation is no longer being maintained and may be removed. If you are running this version, we strongly advise you to upgrade. For the latest information, see the current release documentation.
Has Child Filter
editHas Child Filter
editThe has_child
filter accepts a query and the child type to run
against, and results in parent documents that have child docs matching
the query. Here is an example:
{ "has_child" : { "type" : "blog_tag", "query" : { "term" : { "tag" : "something" } } } }
The type
is the child type to query against. The parent type to return
is automatically detected based on the mappings.
The way that the filter is implemented is by first running the child query, doing the matching up to the parent doc for each document matched.
The has_child
filter also accepts a filter instead of a query:
{ "has_child" : { "type" : "comment", "filter" : { "term" : { "user" : "john" } } } }
Memory Considerations
editWith the current implementation, all _id
values are loaded to memory
(heap) in order to support fast lookups, so make sure there is enough
memory for it.
Caching
editThe has_child
filter cannot be cached in the filter cache. The _cache
and _cache_key
options are a no-op in this filter. Also any filter that
wraps the has_child
filter either directly or indirectly will not be cached.