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 Parent Filter
editHas Parent Filter
editThe has_parent
filter accepts a query and a parent type. The query is
executed in the parent document space, which is specified by the parent
type. This filter returns child documents which associated parents have
matched. For the rest has_parent
filter has the same options and works
in the same manner as the has_child
filter.
The has_parent
filter is available from version 0.19.10
. This is an
experimental filter.
Filter example
edit{ "has_parent" : { "parent_type" : "blog", "query" : { "term" : { "tag" : "something" } } } }
The parent_type
field name can also be abbreviated to type
.
The way that the filter is implemented is by first running the parent query, doing the matching up to the child doc for each document matched.
The has_parent
filter also accepts a filter instead of a query:
{ "has_parent" : { "type" : "blog", "filter" : { "term" : { "text" : "bonsai three" } } } }
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_parent
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_parent
filter either directly or indirectly will not be cached.