Elasticsearch tidbits (this page gets updated over time)

2022, Jul 20    

Filter the results using a text analyzed field

When limiting the search results, as in filtering the results using the term search, the field should be TEXTFIELD.keyword. This is the default behavior of the default analyzer. If we do not analyze the field, only in that case we can directly use term with the exact TEXTFIELD. Below, I am providing a correct example of how to do the filter.

{
    "query":{
        "bool":{
            "filter":[
                {"term":{"TEXTFIELD.keyword":"matching term"}}
            ]
        }
    }
}

Source:https://discuss.elastic.co/t/elastic-term-filter-not-working-when-term-contains/107301