# inFilter() and inQuery() were removed - what to use instead?

**URL:** <https://discuss.elastic.co/t/infilter-and-inquery-were-removed-what-to-use-instead/41233>\
**Category:** Elasticsearch\
**Created:** [February 8, 2016, 11:52pm UTC](https://discuss.elastic.co/t/infilter-and-inquery-were-removed-what-to-use-instead/41233 "2016-02-08T23:52:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tbessie](https://avatars.discourse-cdn.com/v4/letter/t/a698b9/32.png) [@tbessie](https://discuss.elastic.co/u/tbessie)\
**Post date:** [February 8, 2016, 11:52pm UTC](https://discuss.elastic.co/t/infilter-and-inquery-were-removed-what-to-use-instead/41233/1 "2016-02-08T23:52:59Z")

</div>

I'm upgrading from Elasticsearch 1.5 to 2.2, and am trying to fix the code to work with it.

I am using filters, and am changing them all to queries; however, I'm using inFilter(), and there is no longer an inQuery() method. What has this been replaced with?

Also, is there any documentation with more details about the changes from filters to queries besides what's on the "breaking changes/java" page?

- Tim

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 9, 2016, 6:47am UTC](https://discuss.elastic.co/t/infilter-and-inquery-were-removed-what-to-use-instead/41233/2 "2016-02-09T06:47:20Z")

</div>

You're right. There is no mention in documentation about this case.

Actually inQuery has been deprecated for months (years) and when filters have been removed, `inFilter` disappeared as well.

We are probably missing a breaking change here.

@jpountz WDYT?

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [February 9, 2016, 8:18am UTC](https://discuss.elastic.co/t/infilter-and-inquery-were-removed-what-to-use-instead/41233/3 "2016-02-09T08:18:36Z")

</div>

Agreed it should have been documented that inQuery/inFilter should be replaced with `termsQuery`.

---

<div class="post-metadata">

**Author:** ![tbessie](https://avatars.discourse-cdn.com/v4/letter/t/a698b9/32.png) [@tbessie](https://discuss.elastic.co/u/tbessie)\
**Post date:** [February 9, 2016, 8:19am UTC](https://discuss.elastic.co/t/infilter-and-inquery-were-removed-what-to-use-instead/41233/4 "2016-02-09T08:19:20Z")

</div>

Thanks for your reply - hopefully someone will comment on what to use instead. 🙂

Do you happen to know, by the way, if there is any documentation describing why filters were removed and replaced with queries? I had thought the underlying mechanisms of queries and filters were different, and having them as separate entities made things more efficient. What changed such that this merging was necessary, and how does that change in the implementations of what USED to be filters?

- Tim

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [February 9, 2016, 8:31am UTC](https://discuss.elastic.co/t/infilter-and-inquery-were-removed-what-to-use-instead/41233/5 "2016-02-09T08:31:08Z")

</div>

In my opinion, it is more user-friendly this way: you just express what you are searching for, and then elasticsearch figures out by itself where scores are needed.

In terms of implementations, it simplified as well: many queries/filters were duplicated: TermQuery/TermFilter, BooleanQuery/BooleanFilter, etc. now we only have the query version anymore. Also there used to be 3 ways to perform conjunctions: two queries together with a BooleanQuery, two filters together with a BooleanFilter, and a query and a filter with FilteredQuery. Now everything is handled by BooleanQuery.

Also it is important to realize that queries become filters implicitely sometimes, for instance if you are not sorting based on the score. So this case is now also optimized, even if you used the dsl for queries.

---

<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:18pm UTC](https://discuss.elastic.co/t/infilter-and-inquery-were-removed-what-to-use-instead/41233/6 "2017-07-05T23:18:02Z")

</div>


