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

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

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?

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

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

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

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.