Does it matter if the filter is inside or outside a filtered query?

前端 未结 1 1614
鱼传尺愫
鱼传尺愫 2020-12-13 15:43

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

相关标签:
1条回答
  • 2020-12-13 16:03

    Filter inside a Query

    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

    Filter after a 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.

    0 讨论(0)
提交回复
热议问题