While these two are giving me the same result, what is the difference between having the filter inside or outside? Is there a difference in terms of performance or the actio
Elasticsearch will execute the query and filter in what ever way is more efficient to reduce the results set and get you the answer as quickly as possible. This is referred to as a filtered_query
The query is run first and then results are filtered before returning them to the client. This is referred to as a post_filter.
Although a post_filter is less efficient, it can be useful when combining with an aggregation - the aggregated values won't take into account the post_filter, i.e. the aggregation will only be on the query results.