# Where is boolFilter().cache and hasParentFilter in ES 2.x?

**URL:** <https://discuss.elastic.co/t/where-is-boolfilter-cache-and-hasparentfilter-in-es-2-x/39917>\
**Category:** Elasticsearch\
**Created:** [January 22, 2016, 6:57pm UTC](https://discuss.elastic.co/t/where-is-boolfilter-cache-and-hasparentfilter-in-es-2-x/39917 "2016-01-22T18:57:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![apanimesh061](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/apanimesh061/32/927_2.png) [@apanimesh061](https://discuss.elastic.co/u/apanimesh061)\
**Post date:** [January 22, 2016, 6:57pm UTC](https://discuss.elastic.co/t/where-is-boolfilter-cache-and-hasparentfilter-in-es-2-x/39917/1 "2016-01-22T18:57:01Z")

</div>

Following is a snippet that is compatible with ES 1.x:  
`BoolFilterBuilder boolFilterBuilder = boolFilter().cache(true);`

This is a function present in `FilterBuilders.java`:  
`hasParentFilter(String parentType, QueryBuilder query)`

How do I change the syntax to make it compatible with ES 2.x?  
I could not find any examples?

---

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [January 26, 2016, 9:05am UTC](https://discuss.elastic.co/t/where-is-boolfilter-cache-and-hasparentfilter-in-es-2-x/39917/2 "2016-01-26T09:05:21Z")

</div>

Hi apanimesh061,

the main reason is that [queries and filters have been merged in 2.0](https://www.elastic.co/guide/en/elasticsearch/reference/2.1/breaking_20_query_dsl_changes.html#_queries_and_filters_merged).

To your specific issues:

- `bool` filter [has been replaced by bool query in 2.x](https://www.elastic.co/guide/en/elasticsearch/reference/2.1/query-dsl-bool-filter.html), so you basically have to use [QueryBuilder](https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-query-dsl.html) now.
- Also note that [Elasticsearch decides internally whether to cache a filter](https://www.elastic.co/guide/en/elasticsearch/reference/2.1/breaking_20_query_dsl_changes.html#_filter_auto_caching), so there is no need for a `cache(boolean)` method anymore.
- The `has_parent` filter is now [has\_parent query](https://www.elastic.co/guide/en/elasticsearch/reference/2.1/query-dsl-has-parent-query.html). You can use the `HasParentQueryBuilder` for that.

Daniel

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:21pm UTC](https://discuss.elastic.co/t/where-is-boolfilter-cache-and-hasparentfilter-in-es-2-x/39917/3 "2017-07-05T23:21:40Z")

</div>

Closed on July 5, 2017, 11:21pm UTC


