Execution of term query in filter context


(Anirudh Modi) #1

Prior to elastic 2.0 there was term filter and term query., where the term query use to work on analyzed field and the term filter use to work on the non-analyzed field.

Now, elasticsearch 2.x we are supposed to use term query in filter context to get the desired effect, however I am confused about the fact that with new changes will the term filter work on both analyzed and non-analyzed or just on non-analyzed field?


(Jörg Prante) #2

Analyzed/non-analyzed is not related to query or filter context. You can address the field as you like.

Example for searching a term in query context

termQuery("foo1", "bar1")

Example for searching a term in filter context

boolQuery().must(matchAllQuery()).filter(termQuery("foo2", "bar2"))


(system) #3